System.UnauthorizedAccessException while running .exe under program files

Don’t try to write where applications should not write. Use other folders like for example:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

If there is no possible alternative, which I seriously doubt, run the executable with administrative privileges.

https://msdn.microsoft.com/en-us/library/bb756929.aspx

Leave a Comment