Directory.Delete既不删除也不引发异常 [英] Directory.Delete is neither deleting or nor raising the exception

查看:187
本文介绍了Directory.Delete既不删除也不引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   我遇到了一些奇怪的情况,其中Directory.Delete没有引发异常,同时没有删除文件夹。 

    I came through some strange scenario, where Directory.Delete is not raising the exception and at the same time not deleting the folder. 

在我们删除文件夹之前,所有文件都在文件夹已删除。到时,调用Directory.Delete,文件夹为空。当我调用它时,目录不会被删除,但也不会引发异常。我可以看到该文件夹​​。如果我们尝试访问
文件夹,我将收到Access Denied错误。这时,如果我重新启动机器,那么重启后我再也看不到该文件夹​​了。是这样的,Windows在重启或Directory.Delete需要一些时间来删除
文件夹时要小心吗?在删除文件夹之前,我们自己的服务使用了该文件夹中的文件。如果存在任何访问问题,它应该引发异常并且不应该删除文件。请查看下面的示例代码。 

Before we delete the folder, all the files in the folders are deleted. By the time, Directory.Delete is called, folder is empty. When I called this, directory is not deleted but the exception is also not raised. I can see the folder. If we try to access the folder, I am getting Access Denied error. At this time, if I restart the machine, then I dont see the folder again after the restart. Is this something like, windows is taking care while doing the restart or Directory.Delete is taking some time to delete the folder? Before deleting the folder, files in the folder was used by our own service. If there is any access issue, it should have raised the exception and it should not have deleted the files. Please check sample code below. 

问候

Nagaraju

推荐答案

您好,

请参阅以下
讨论


这篇关于Directory.Delete既不删除也不引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆