简体   繁体   English

访问路径“C 被拒绝”。

[英]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.DeleteFile.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.

相关问题 访问路径被拒绝。 在 c# - Access to the path is denied. in c# 对路径的访问被拒绝。 - Access to the path is denied. 拒绝访问“ somepath”路径。” - Access to the path “somepath” is denied." C# 对路径的访问被拒绝...(System.UnauthorizedAccessException:对路径'C:\'的访问被拒绝。) - C# access to the path is denied…(System.UnauthorizedAccessException: Access to the path 'C:\' is denied.) UWP FileStream 抛出“对路径的访问被拒绝”。 - UWP FileStream throws "Access to path is denied." UNC路径中的C#ASP.NET File.OpenRead:“对路径的访问...被拒绝。” - C# ASP.NET File.OpenRead from UNC path: “Access to path…is denied.” RegistrySecurity访问被拒绝。 C# - RegistrySecurity Access is denied. C# 创建新目录将返回错误:“ System.UnauthorizedAccessException:'对路径'C:\\ Users'的访问被拒绝。 - Creating new directory returns error :"System.UnauthorizedAccessException : 'Access to the path 'C:\Users' is denied.' 使用 IronPDF 将 HTML 转换为 PDF 时出现错误“访问路径 'IronPdf.ChromeRenderingEngine.dll' 被拒绝。” 在 C# 中 - HTML to PDF using ironPDF getting error "access to the path 'IronPdf.ChromeRenderingEngine.dll' is denied." in C# 拒绝访问路径。 谷歌api本地iis发布 - Access to the path is denied. google api local iis publish
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM