Alessandro Mandelli
Alessandro Mandelli

Reputation: 581

Converted WinForm app can't write-access WindowsApps folder

everybody. Sorry if I ask something trivial. I looked into the previously asked questions, to no avail. If the question was already asked, I beg your excuses, and please point me in the right direction. I have a number of single form WinForms apps that I'm in the process of converting to appx for the store. So far so good. No issues with that. Despite, one of my apps uses the application folder to save some data to a temporary file

Dim sw As New StreamWriter(Application.StartupPath + "\somefile.csv", True)

The .exe program of course works with no issue. The converted .appx program complains that I have no write permission to the WindowsApps and it subfolders. I quickly solved by taking ownership of the folder and give myself full control over it.

Do I have any chance to prevent the error message to appear on a generic machine, other than trivially changing the source code to point the temporary folder to some other path? Clearly I don't want the admin to give the user full control over WindowsApps folder.

Upvotes: 0

Views: 113

Answers (1)

Stefan Wick  MSFT
Stefan Wick MSFT

Reputation: 13850

Writing to the package folder is not allowed. You need to change your code to write to a location that is writeable for the app/user, for example to the AppData folder.

This is documented in the Desktop Bridge preparation guide: https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-prepare

(it's the eighth bullet point)

Upvotes: 2

Related Questions