copying file to a directory(c: or c:program files) that i dont have permission [duplicate]

孤街醉人 提交于 2019-12-23 04:15:26

问题


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://


回答1:


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.




回答2:


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.




回答3:


You can't. You have to give the user permissions.



来源:https://stackoverflow.com/questions/6010472/copying-file-to-a-directoryc-or-cprogram-files-that-i-dont-have-permission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!