copying file to a directory(c: or c:program files) that i dont have permission [duplicate]
Possible Duplicate:
Allow access permission to write in Program Files of Windows 7
okay, here is my code :
System.IO.File.WriteAllBytes(path1, path2);
however, there is a 开发者_运维问答problem. user(windows 7 users dont have permission to copy file to c: by default)(...i mean for programs...) therefore, program fails. if user gives permission to copy file in c: program works fine. but you cant tell every user " go to permission.........." so how can i make something to allow user that i copy my file to c://
You may add the Application Manifest File
in your project by Selection Add New Item
. Update the requestedExecutionLevel
to
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
This way user will be asked that the application needs to run in Administrative mode. Hope this help.
Your application shouldn't be writing to the C drive
. Only users with permission, or administrators, can grant an application to do that. Instead, try writing to folders that aren't limited by tight security. You can see some of them here.
You can't. You have to give the user permissions.
精彩评论