locked
How to relocate 'Assets' folder for Windows Store apps? RRS feed

  • Question

  • Hello!

    I would like to ask if and how it is possible to relocate 'Assets' folder when using it in Windows Store apps? I am using image files in Asset folder (currently located in the base root folder for the application) for displaying in my Windows Store app, but when I deploy to a user, I want the 'Asset' folder to be copied and accessed instead from the User's My Documents folder.

    Is this possible? How can I do this? Because it is troublesome to have the user navigate to the application's installation folder to put the 'Assets' folder there.

    Thank you!

    Monday, November 26, 2012 4:25 AM

Answers

  • You cannot "relocate" this folder but you can copy all the files when the app is started for the first time. You can do it by handling app's OnLaunched event and checking PreviousExecutionState for the args.
    • Marked as answer by OCS.New Monday, November 26, 2012 7:57 AM
    Monday, November 26, 2012 5:11 AM
  • Hello,

    This is how you can access the applications folder in code (to copy stuff etc.): http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/32924a11-9e33-4a1e-8f14-cd1854e79f96/#ea99b594-0557-4442-b547-757e0635b207

    This is what a reference to a file in the Assets folder looks like:

    "ms-appx:/Assets/SmallLogo.png"

    You can't reference things like D:\blabla\foo.png, because Windows Store/Metro apps are sandboxed and only have access to folders the user granted it.

    You should always have in mind, that most users don't want to see your apps internal stuff and have it mess around on the hard drive!

    ~theCake


    Life is unsure - always eat the dessert first!

    • Marked as answer by OCS.New Monday, November 26, 2012 7:57 AM
    Monday, November 26, 2012 7:54 AM

All replies

  • You cannot "relocate" this folder but you can copy all the files when the app is started for the first time. You can do it by handling app's OnLaunched event and checking PreviousExecutionState for the args.
    • Marked as answer by OCS.New Monday, November 26, 2012 7:57 AM
    Monday, November 26, 2012 5:11 AM
  • Thanks for the reply! Hmm, ok I'll try something like that.

    Monday, November 26, 2012 5:22 AM
  • Hello there! I've tried it and it is taking my app quite sometime to load.

    Any other alternatives? Is it possible to reference an Image Source to an absolute path? I've tried something like: "file:///D:/image.jpg" but it does not work.

    Thank you!

    Monday, November 26, 2012 5:52 AM
  • Hello,

    This is how you can access the applications folder in code (to copy stuff etc.): http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/32924a11-9e33-4a1e-8f14-cd1854e79f96/#ea99b594-0557-4442-b547-757e0635b207

    This is what a reference to a file in the Assets folder looks like:

    "ms-appx:/Assets/SmallLogo.png"

    You can't reference things like D:\blabla\foo.png, because Windows Store/Metro apps are sandboxed and only have access to folders the user granted it.

    You should always have in mind, that most users don't want to see your apps internal stuff and have it mess around on the hard drive!

    ~theCake


    Life is unsure - always eat the dessert first!

    • Marked as answer by OCS.New Monday, November 26, 2012 7:57 AM
    Monday, November 26, 2012 7:54 AM