将文件复制到我没有权限的目录(c:或c:program文件) [英] copying file to a directory(c: or c:program files) that i dont have permission

查看:102
本文介绍了将文件复制到我没有权限的目录(c:或c:program文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
允许访问权限以在Windows的程序文件中写入7

Possible Duplicate:
Allow access permission to write in Program Files of Windows 7

好的,这是我的代码:

System.IO.File.WriteAllBytes(path1, path2);

但是,有一个问题. 用户(Windows 7用户默认无权将文件复制到c:)(...我的意思是程序...) 因此,程序失败. 如果用户允许在c:程序中复制文件,则工作正常.但是您不能告诉每个用户获得许可..........",所以我该如何做一些事情让用户将文件复制到c://

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

推荐答案

您可以通过选择Add New Item在项目中添加Application Manifest File.将requestedExecutionLevel更新为

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.

这篇关于将文件复制到我没有权限的目录(c:或c:program文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆