简体   繁体   English

删除dll时出现System.UnauthorizedAccessException

[英]System.UnauthorizedAccessException while deleting dll

While deleting my .dll file System.UnauthorizedAccessException was thrown. 删除我的.dll文件时,引发了System.UnauthorizedAccessException。

System.IO.File.Delete("file name here.dll");

Error message is as follows: 错误信息如下:

System.UnauthorizedAccessException: Access to the path 'E:\\Projeler\\Spa Anahtar Üretici\\ConsoleApplication2\\bin\\Debug\\AutoGen.dll' is denied. System.UnauthorizedAccessException:拒绝访问路径“ E:\\ Projeler \\ Spa AnahtarÜretici\\ ConsoleApplication2 \\ bin \\ Debug \\ AutoGen.dll”。

How to solve this problem? 如何解决这个问题呢?

Try opening the file using File.Open method and enclose it in try-catch with exception IOException. 尝试使用File.Open方法打开文件,并将其包含在try-catch中,并带有IOException异常。

If the file is in use , the code flow reaches the exception part and hence don't delete the file, Otherwise you can safely delete. 如果文件正在使用中,则代码流到达异常部分,因此请不要删除该文件,否则可以安全删除。

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

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