locked
Where to store a data file? RRS feed

  • Question

  • Hi,

    I have a list of about 1000 items in a text file.  I want to access this file occasionaly for data in my app.  Where do I save this file and how do I access it?

    Thanks

    Sunday, February 24, 2013 3:52 AM

Answers

  • That's a place to store things at run-time. If the file is static and you want to install it with your project then choose the file's properties in the Solution Explorer and mark the file as content and to copy to the output directory.

    You can read it in at runtime with the file API as described in Quickstart: Accessing files programmatically .

    --Rob

    Sunday, February 24, 2013 4:42 AM
    Moderator

All replies

  • I'd put it in your RoamingFolder.

    Please see  Accessing app data with the Windows Runtime for more details.

    --Rob

    Sunday, February 24, 2013 3:58 AM
    Moderator
  • Thanks for the quick reply.  Why cant I find that folder in the solution explorer? How do I put the file in the roaming folder?

    Thank you

    Sunday, February 24, 2013 4:08 AM
  • That's a place to store things at run-time. If the file is static and you want to install it with your project then choose the file's properties in the Solution Explorer and mark the file as content and to copy to the output directory.

    You can read it in at runtime with the file API as described in Quickstart: Accessing files programmatically .

    --Rob

    Sunday, February 24, 2013 4:42 AM
    Moderator
  • Thanks again,

    I have now marked it to copy to the output directory.  My code(within the onActivated function) is still giving me trouble:

     var package1 = Windows.ApplicationModel.Package.current;
     var installedLocation = package1.installedLocation;

                  
    installedLocation.getFileAsync("myDataList.com.txt")
    .then(function (myFile) {
          return Windows.Storage.FileIO.readTextAsync(myFile);
        }).done(function (fileResult) {
                       
                        var msg1 = new Windows.UI.Popups.MessageDialog("Success"); msg1.showAsync();
                    }, function () { var messageDialog = new Windows.UI.Popups.MessageDialog("Error"); messageDialog.showAsync();});

    I keep getting the error popup.

    Sunday, February 24, 2013 5:02 AM
  • I think I got it working.  Thanks for your help.
    Sunday, February 24, 2013 5:44 AM