Search code examples
c#pathuwpresourcesfolder-access

I want to access resources in uwp


Firstly, sorry this beginner's question.

But i'm really don't know the concept of path

I want to save my image files on uwp's resources History folder that i created.

So that I can open that images or save them.

enter image description here

But i can't find a way how to access my own folder

I tried appdata.localfolder but that's not for me

Anyone know the solution to this?

Thank you for reading this !


Solution

  • The images in the History folder are part of the program and are built to the package's installation directory. You can take it the equivalent of the C:\Program Files\Your App folder, the files are read-only.

    To access the files from the History folder, use

    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///History/yourfile.jpg"));
    

    AppData.LocalFolder on the other hand, is your app's data folder, that is where the app data files - files that generated by the app - are located, and you can save app data there.

    You can refer to this for how to write to the app data folder.