Search code examples
c#msix

MSIX cant create folders in AppData


I have an application that is being installed from MSIX installer. It is installing successfully, but when execute it after installation i get an error that there is no such a file in C:/UserName/AppData/Roaming/MyApplication.

What i have tried:

  1. Creating the folder (from C# code) on the very beggining of the application.

Result: It was creating it somewhere, but i couldnt see it on a disk apparently. Even when i tried creating files in that directory, i could do it without exception. So im sure that this folder existed. Somewhere. When i ran application from MSIX it gave me previously mentioned exception.

  1. I created folder from the OS manually to see if the error will persist.

Result: I ran application from MSIX and everything worked fine.

  1. At the last step i tried to access priviliges to the C:/WindowsApp folder (thats where MSIX are installing things), and i tried to run application from there manually by executing .exe (not by MSIX like previous times), to see if the error will last.

Result: It created those folders without problems, and application worked fine.

Any ideas what im doing wrong, or what i could do avoid this error ?

PS. I cannot change location of path C:/UserName/AppData/Roaming/MyApplication, because it is being created by 3rd parties dll's (Devexpress).


Solution

    1. Try searching for the files under this path:

    C:\Users\User\AppData\Local\Packages(hash)....

    That is where all MSIX packaged apps redirect their AppData resources.

    However, if the files are found to be existing in the "real" AppData folder, the app will work with that copy, not the one from the virtualized location (this is international behavior from Microsoft, to smoothen the transition of apps from classic installers to MSIX). That is why the application worked after you created the folder manually.

    Also, note that the files from the virtualized location are accessible only to your application and can't be accessed by others from the machine.

    1. I suspect that when run the EXE directly from the install folder (not from the start menu entry point) the OS does not launch app in the container of the MSIX package, so none of the rules of running as a packaged-app apply. Therefore you can ignore this scenario.

    Go back to #1 and try searching for the files under the path I mentioned. How are you (Devexpress) accessing the AppData path? I assume they are using something in the lines of (this should be ok):

    Environment.GetFolderPath(Environment.SpecialFolder.)