将文件复制到我没有权限的目录(c: 或 c:program files)
好的,这是我的代码:
System.IO.File.WriteAllBytes(path1, path2);
但是,有一个问题。 用户(Windows 7 用户默认无权将文件复制到 c:)(...我的意思是程序...) 因此,程序失败。 如果用户授予在 c: 中复制文件的权限,则程序可以正常工作。但你不能告诉每个用户“转到权限..............”所以我怎样才能做一些事情来允许用户将我的文件复制到 c://
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://
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过选择
添加新项
在您的项目中添加应用程序清单文件
。将requestedExecutionLevel
更新为这样,系统将询问用户应用程序需要在管理模式下运行。希望这有帮助。
You may add the
Application Manifest File
in your project by SelectionAdd New Item
. Update therequestedExecutionLevel
toThis way user will be asked that the application needs to run in Administrative mode. Hope this help.
您的应用程序不应写入
C 驱动器
。只有具有权限的用户或管理员才能授权应用程序执行此操作。相反,请尝试写入不受严格安全限制的文件夹。您可以此处查看其中的一些。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.