使用wpf c#在C:\\Program Files \\权限访问中创建/复制文件/文件夹 [英] File/Folder create/copy inside C:\\Program Files\\ permission access using wpf c#
本文介绍了使用wpf c#在C:\\Program Files \\权限访问中创建/复制文件/文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码在C:\\Program Files \\中创建文件夹:
Directory.CreateDirectory(C:\\Program Files \\ folderName)。
但显示异常为:访问路径' 'C:\ Program Files \ folderName''被拒绝。
请帮帮我。
谢谢,
Hi,
I am trying to create folder in C:\\Program Files\\ using code like this:
Directory.CreateDirectory("C:\\Program Files\\folderName").
But showing exception as : Access to the path ''C:\Program Files\folderName'' is denied.
Please help me out.
Thanks,
推荐答案
权限问题的两种解决方案:
你需要设置适当的权限从源读取并写入目标位置为用户的exe。
或
您可以 冒充 拥有此类权限的用户(在代码中,使用凭据另一个执行操作的用户)。
** 参见完整版C#.NET中的模拟演示 [ ^ ]
干杯,
Edo
Two solutions to the permissions problem:
You need to set the appropriate permissions to Read from the source and Write to the target location for the user(s) of the exe.
OR
You can impersonate a user with such permissions (in the code, use the credentials of another user to perform the action).
** See A complete Impersonation Demo in C#.NET[^]
Cheers,
Edo
>
这篇关于使用wpf c#在C:\\Program Files \\权限访问中创建/复制文件/文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文