简体   繁体   English

在Windows 10中访问c:\\ Programdata中的文件时访问被拒绝

[英]Access denied while accessing files in c:\Programdata in Windows 10

I am designing an command line application for Windows 10 that require to replace some files in c:\\programdata folder. 我正在为Windows 10设计一个命令行应用程序,该应用程序需要替换c:\\programdata文件夹中的某些文件。 But when I use File.Copy or File.Move , it throws an exception as: 但是,当我使用File.CopyFile.Move ,它将引发以下异常:

Access to the path 'C:\\ProgramData\\***' is denied. 拒绝访问路径“ C:\\ ProgramData \\ ***”。

I have added app.manifest with requireAdministrator but it doesn't work. 我已经用requireAdministrator添加了app.manifest ,但是它不起作用。 Am I missing something? 我想念什么吗?

Make sure you have permissions on that folder. 确保您对该文件夹具有权限。 eg Right Click on folder > Properties > go to Security tab, and check if you have permissions. 例如,右键单击文件夹>属性>转到“安全性”选项卡,然后检查您是否具有权限。 Also try your application by right click and 'Run as Administrator'. 也可以通过右键单击“以管理员身份运行”来尝试您的应用程序。

Try to check the user identity the actually runs the process/execute file. 尝试检查实际运行进程/执行文件的用户身份。

This user should by "System" to have permissions to Move/Copy files on the Disk. 该用户应通过“系统”拥有在磁盘上移动/复制文件的权限。

In debug mode you can always check the Task Manager => Processes and see the User Name for your process. 在调试模式下,您始终可以检查任务管理器=>进程,并查看进程的用户名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM