1
votes

I have a desktop app which I am converting to UWP(Universal Windows Platform) app using MSIX packaging tool. I have resources folder for my app which is getting copied to AppData/Roaming Folder on installing the msi.
But when I install the msix then my resources folder is getting copied to below path :

C:\Program Files\WindowsApps\<XXXXXXXXXXXX>_2.2.1.0_x86__9r3t3jamfgx9p\**VFS\AppData**

The resources folder is having database files, log file & some important packages which I need to access from my c# code.

I need to access the resources folder pragmatically. How can I access this path? Or will it get copied to some other path where I can have access

I have also checked the below path for resources folder but it is not there.

C:\Users\akshay.verma\**AppData\Local\Packages**\<XXXXXXX>

Please help me with how can I access my resources folder from c# code.

1
My problem is similar to this : stackoverflow.com/questions/48849076/… There is a line from the above link that : The writes you performed in your code did actually work, but they did not write into the AppData\Roaming folder, but to a virtualized counterpart of this folder, which you can find in: AppData\Local\Packages\{your app's ID}\LocalCache\Roaming\. But the problem is I Couldn't find the resources folder here.Akshay Verma
I answered something similar recently and may be very helpful to you: stackoverflow.com/questions/57139554/…Jason Roner
If below answer is helpful please mark it thx.Nico Zhu - MSFT

1 Answers

0
votes

C:\Program Files\WindowsApps\_2.2.1.0_x86__9r3t3jamfgx9p**VFS\AppData**

The above path is app's sandbox path, you could use Windows Storage ApI to access above path. For example:

var LocaFolder =  ApplicationData.Current.LocalFolder;

If the resource file stored in the installed location (C:\Users\akshay.verma\**AppData\Local\Packages**\<XXXXXXX>) you could acess installation folder with the following. Then use GetFolderAsync method to get the sub folder.

StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFolder Resource = await appInstalledFolder.GetFolderAsync("Resource");
var files = await Resource.GetFilesAsync();

After get the target file, you could call CopyAsync method copy the file to the destination folder. And the following shows that how to copy the folder.

public static async Task CopyFolderAsync(StorageFolder source, StorageFolder destinationContainer, string desiredName = null)
{
    StorageFolder destinationFolder = null;
        destinationFolder = await destinationContainer.CreateFolderAsync(
            desiredName ?? source.Name, CreationCollisionOption.ReplaceExisting);

    foreach (var file in await source.GetFilesAsync())
    {
        await file.CopyAsync(destinationFolder, file.Name, NameCollisionOption.ReplaceExisting);
    }
    foreach (var folder in await source.GetFoldersAsync())
    {
        await CopyFolderAsync(folder, destinationFolder);
    }
}

For more info please refer UWP file access permissions .