I'm working on a WPF application where the user sets the target path for an xml file to be created, but I'm always getting an UnauthorizedAccessException, even if the target directory is in my own computer.
I've already tried replacing <requestedExecutionLevel level="asInvoker" uiAccess="false" />
with <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
in the app.manifest file to force the program to run as administrator but it didn't work either.
The exception message I get is
Access to the path [path] is denied
What do I need to do to solve this problem?
Thank you.
The solution I found for this issue was to create a folder inside the target directory set by the user with the following code:
DirectoryInfo info = Directory.CreateDirectory(myPath);
Then, set the program to create the xml file inside that newly created folder.