更新时间:2022-10-16 18:56:29
You have to assume that you might not have permission to access some files and folders on your hard drive.
One solution is to manually run your application with administrator-level permissions, but it is easier to modify the manifest file so that the application automatically seeks admin level when it is run.
You can do this by adding a mainifest file to your project (Add new item...).
Then change the line
<requestedExecutionLevel level="asInvoker" uiAccess="false" />"
to
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />"
Obviously, this might not solve your problem if the user who is meant to run the program does not have an administrator-level account.