等待系统删除文件 [英] Waiting for system to delete file
问题描述
经过一些思考和调试,我来得出结论,问题在于系统需要一些时间来删除文件。我解决这个问题:
$ p $ //删除文件
System.Threading.Thread.Sleep(2000);
//刷新列表
它工作正常。
我的问题是 有没有更优雅的方法来等待系统删除文件,然后继续执行代码...? 我能想到的最优雅的方式是使用 FileSystemWatcher 并订阅其 I had a problem with refreshing file list after deleting a file. When I gave command to delete file, the exception was thrown because the refresh method tried to access a file that was supposed to be deleted. After some thought and debuging I came to conclusion that problem was in a fact that system needs some time to delete a file. And I solve it like this: and it worked fine. My question is Is there a more elegant way to wait for system do delete file and then continue with code...? The most elegant way I can think of is using a FileSystemWatcher and subscribe to its 这篇关于等待系统删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
已删除的
事件。 //Deleting file
System.Threading.Thread.Sleep(2000);
//Refreshing list
Deleted
event.