locked
Using fopen( ) to access files in Application Data Local.

    Question

  • We need to access some data files that we would include in our application package from a rather large code base of legacy/native C++.  We should be able to use fope() according to many posts on this forum, which make some form of the following statement:

    "Metro style apps do not have permissions to most of the file system, only to files within their install location and application data store. You should be able to use fopen in those locations, but not elsewhere."  from the post titled: "File open fails with permission denied error(fopen())".

    Here is my first attempt:

      FILE *fd = fopen("ms-appdata:///local/license.txt", "r");

    This fails with hr = 0x0000007b : The filename, directory name, or volume label syntax is incorrect.

    Is the "ms-appdata:///local/" acceptable, or do we need to build a full path name using:

      Windows::Storage::ApplicationData::Current->LocalFolder->Path;

    When we include the file "license.txt" in our project, and mark it as type "Content", where does this file get copied to in the app folder?

    Is it possible to create a directory hierarchy of application data files and have it installed through the app package?

    Thursday, May 7, 2015 6:16 PM

Answers

  • fopen() takes a path as an argument. It doesn't know what to do with URIs such as ms-appdata:///....

    Files included in the project will be in the Windows::ApplicationModel::Package::Current::InstalledLocation not in the ApplicationData.

    If you want to pre-populate application data you can include your data in the appxpackage and copy it to AppicationData::LocalFolder when the app first runs.

    Thursday, May 7, 2015 6:54 PM
    Owner
  • This forum is for publicly available developer environments only. For XBox specific questions you'll need to go through the channels you got the XDK from.
    Tuesday, May 12, 2015 5:52 PM
    Owner

All replies

  • fopen() takes a path as an argument. It doesn't know what to do with URIs such as ms-appdata:///....

    Files included in the project will be in the Windows::ApplicationModel::Package::Current::InstalledLocation not in the ApplicationData.

    If you want to pre-populate application data you can include your data in the appxpackage and copy it to AppicationData::LocalFolder when the app first runs.

    Thursday, May 7, 2015 6:54 PM
    Owner
  • This forum is for publicly available developer environments only. For XBox specific questions you'll need to go through the channels you got the XDK from.
    Tuesday, May 12, 2015 5:52 PM
    Owner