'How to include externel user files into UWP side-loading package?

Say I use some .json files to descript some object data which effect to the program's behavior, I hope to use these files in the following scenarios

  1. The default values, for this purpose, I need a set of files follows with the application to be packed and installed.

  2. I wish it could be edited by human manually. (Because something have no interface to be modify on UI)

Both user and the program need to kwnow the location the files will be placed after installation.

In debugging stage, I could put these files in the user\AppData\Local.. folder and I know how to access them, but I don't know how to put files into the package and will them generated to anywhere after install?

Thank you for any suggestion.

ps.

  • I use the "Blank App (WinUI 3 in UWP)" template to create my application.
  • I'm new in UWP and WinUI, I used to write traditional Windows Form programs.


Solution 1:[1]

How to include externel user files into UWP side-loading package?

You could place the json file into app's project and set the file property as Content, then it will deploy into installtion folder after package install. and please note the json file is readonly in the installtion folder. so you could call CopyAsync method copy the file to the destination folder that app's local folder with full permission.

For more details about file access permissions please refer this document.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nico Zhu - MSFT