locked
Apparently build location != installed location when debugging. How do you handle this? RRS feed

  • Question

  • I have files in my assets directory I would like to copy to the users folder.  Using:

    Windows.ApplicationModel.Package.Current.InstalledLocation

    The directory it returns is  ....\bin\Debug\AppX, and I then get the assets directory relative to this: ....\bin\Debug\AppX\Assets

    However, the compiler actually copies my files to .../bin/Debug/Assets, and I don't know how to access this at run time, or how to tell my app isn't installed so I know it's not in ....\bin\Debug\AppX\Assets.

    Yours in confusion,

    Larry Maturo



    Larry Maturo

    Friday, September 13, 2013 9:12 PM

Answers

  • I found the problem.  Some of the files where not in the main project, and they were not set to"Always Copy to Output".

    Larry Maturo

    • Marked as answer by Anne Jing Friday, September 20, 2013 1:37 AM
    Friday, September 13, 2013 10:11 PM

All replies

  • You can acces the "Assets" Folder like this:

    StorageFolder assets = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");

    It's the same for Debug and Release mode.

    At first run you can then copy the files to your ApplicationData, or any other Folder.

    For example:

    StorageFile logo = await assets.GetFileAsync("Logo.scale-100.png");
    await logo.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);

    cheers


    Life is unsure - always eat the dessert first!

    Friday, September 13, 2013 9:36 PM
  • That gets me: ...\bin\Debug\AppX\Assets, but this is not where the files are. The compiler copied them to .../bin/Debug/Assets  How do I get the compiler to copy them to  ...\bin\Debug\AppX\Assets instead, which would be the better solution.

    Larry Maturo

    Friday, September 13, 2013 9:56 PM
  • Then check the build properties of the files in the Solution Explorer - they have to be set to Content and Copy Always.

    Life is unsure - always eat the dessert first!

    Friday, September 13, 2013 10:10 PM
  • I found the problem.  Some of the files where not in the main project, and they were not set to"Always Copy to Output".

    Larry Maturo

    • Marked as answer by Anne Jing Friday, September 20, 2013 1:37 AM
    Friday, September 13, 2013 10:11 PM