3

如果这个问题太简单了,我很抱歉,我是这个主题的新手。

我正在创建一些文件,并且需要等到它们完成或直到经过一段时间(这就是我所说的超时)。

FileSystemWatcher非常适合“等到它们完成”,但我看不到可以控制其寿命的参数。

使用Tread.Sleep似乎违背了目的(?) - 如果它的用法是正确的,FileSystemWatcher就不会存在,我们只会Tread.Sleep while !File.Exists.

那么,实现它的最简单正确的方法是什么?谢谢。

4

1 回答 1

5

FileSystemWatcher.WaitForChanged 方法

MSDN系统

A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor and the time (in milliseconds) to wait before timing out.

于 2013-06-27T11:10:06.313 回答