当用户无权复制文件时提示 UAC
在我的应用程序中,如果用户将文件保存到他们没有权限的文件夹中,File.Copy
将失败。一个示例是将文档保存到 C:\ 根目录。
我不想拒绝访问,而是想通过 UAC 提示提示用户提升权限,但仅限于此保存功能(不适用于整个应用程序)。有办法做到这一点吗?
In my application, if the user saves a file to a folder they don't have permissions for, File.Copy
will fail. An example is saving a document to the C:\ root.
Instead of denying access, I'd like to prompt the user to elevate permissions with a UAC prompt, but only for this save function (not for the entire application). Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之...不。
整个过程需要提升,并且这种提升需要在启动时进行。然而!您可以创建一个单独的流程来完成这项工作。创建一个单独的 .exe,仅执行此工作并在命令行参数中获取所需的所有内容。您可以在流程中添加动词,从而使其提升:
类似这样的事情......
In short... no.
The entire process needs to be elevated and that elevation needs to happen at startup. However! You can create a separate process to do this work. Make a separate .exe that does only this work and gets everything it needs in the command line parameters. You can add verbs to the process that will cause it to be elevated:
Something like that...