将文件复制到我没有权限的目录(c:或c:程序文件)

For*_*esp 1 c# permissions file-permissions path visual-studio

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

好的,这是我的代码:

System.IO.File.WriteAllBytes(path1, path2);
Run Code Online (Sandbox Code Playgroud)

但是,有一个问题.用户(Windows 7用户没有权限将文件复制到c:默认情况下)(...我的意思是程序...)因此,程序失败.如果用户允许在c中复制文件:程序运行正常.但你不能告诉每个用户"去许可.........."所以我怎样才能让用户将我的文件复制到c://

FIr*_*nda 6

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

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)

这样,将要求用户该应用程序需要以管理模式运行.希望这有帮助.