Home >Backend Development >C++ >Why Does Running an EXE in Program Files Cause a System.UnauthorizedAccessException?
System.UnauthorizedAccessException Error When Running EXEs from Program Files
When installing executables (.exe files) into the C:Program Files
directory using WiX, attempting to run them might trigger a System.UnauthorizedAccessException
. This is because the Program Files directory has strict security permissions that prevent standard user accounts from writing to it.
Here's how to address this common problem:
<code class="language-csharp">Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)</code>
This approach grants the necessary permissions to overcome the access restriction.
The above is the detailed content of Why Does Running an EXE in Program Files Cause a System.UnauthorizedAccessException?. For more information, please follow other related articles on the PHP Chinese website!