I have a WINUI 3 application in which I have add multiple of my own text files/photos. However, when I package the app and download the exe through the package, it tries to load those files from C:\Program Files\WindowsApps\PackageName\FilePath. Which rightfully so gives it access denied error.
Code:
public static string ProjBaseDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
public static string CountriesListPath = Path.Combine(ProjBaseDirectory, @"Assets\Contents\Docs\Countries.txt");
Above is how I try to access most of the files, and the path I get from that when debugging is C:\user\Projects\iAssist\iAssist\bin\x64\Debug\net6.0-windows10.0.19041.0\win10-x64\AppX\Assets\Contents\Docs\Countries.txt
But the same line gives me the path to C:\Program Files\WindowsApps\PackageName\FilePath when packaging it.
Properties: Other files/images properties mimic this one.
I have been trying out multiple solution like trying different options for Build Action for the properties of the files, but nothing seems to work. Is there any work around this problem, any help would be highly appreciated, I have been stuck on this problem for two days now.
Thank You!
Let me show you an example based on @Simon Mourier comment about
Windows.Storage.ApplicationData.In this example, I added a text file, SomeText.txt, to the Assets folder in the project.
MainPage.xaml
MainPage.xaml.cs