[英]Access to the path 'C is denied.'
I use File.Delete
to delete a .exe
file in the C drive.我使用File.Delete
删除 C 驱动器中的一个.exe
文件。 But it says I don't have access to delete it.但是它说我无权删除它。 Now I want to use File.Delete
and File.Move
to do it, I tried running VS with Admin rights but it didn't work.现在我想使用File.Delete
和File.Move
来完成它,我尝试使用管理员权限运行 VS,但它没有用。 I want to work with C drive, not another drive.我想使用 C 驱动器,而不是另一个驱动器。 Thank you P/s: I tried the mentioned solutions with the same problem, but it didn't work for me.谢谢 P/s: 我用同样的问题尝试了提到的解决方案,但它对我没有用。
File.Delete(@"C:\Program Files (x86)\ProgramName\FileName.exe");
File.Move(@"newFileName.exe", @"C:\Program Files (x86)\ProgramName\");
How do I force my .NET application to run as administrator? 如何强制我的 .NET 应用程序以管理员身份运行?
Try checking out this link, your application should be running as administrator to have privilege and look for second solution which is provided by Hassan Rahman尝试查看此链接,您的应用程序应该以管理员身份运行以获得特权并寻找Hassan Rahman提供的第二个解决方案
I hope it will resolve your query.我希望它能解决您的查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.