This is the part that crashes and gives me this error when I try to copy a file to a specific location.
string startupDirectory = "C:\\Users\\Tyler\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"; File.Copy(startupDirectory, "Startup.exe");
I read online and tried admin rights and created the app.manifest file:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
I confirmed that in the settings the application manifest is set to this file, but it still gives me the same error.
I also tried this event, although I did not think that it would work, because it is a directory, not a file:
File.SetAttributes(startupDirectory, FileAttributes.Normal);
These are WinForms and I am on Windows 7, but also want it to be in the world for Windows 8+. How to do it?
Thanks in advance!
source share