FileSystemWatcher.WaitForChanged 方法

定義

同步方法,傳回含有發生的變更之特定資訊的結構。

多載

WaitForChanged(WatcherChangeTypes)

提供想要監視的變更類型,同步方法會傳回含有發生的變更之特定資訊的結構。

WaitForChanged(WatcherChangeTypes, Int32)

提供您想要監視的變更類型和逾時前的等候時間 (以毫秒計),同步方法會傳回含有發生的變更之特定資訊的結構。

WaitForChanged(WatcherChangeTypes, TimeSpan)

根據要監視的變更類型,以同步方式傳回結構,其中包含所發生變更的特定資訊。

WaitForChanged(WatcherChangeTypes)

來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs

提供想要監視的變更類型,同步方法會傳回含有發生的變更之特定資訊的結構。

public:
 System::IO::WaitForChangedResult WaitForChanged(System::IO::WatcherChangeTypes changeType);
public System.IO.WaitForChangedResult WaitForChanged (System.IO.WatcherChangeTypes changeType);
member this.WaitForChanged : System.IO.WatcherChangeTypes -> System.IO.WaitForChangedResult
Public Function WaitForChanged (changeType As WatcherChangeTypes) As WaitForChangedResult

參數

changeType
WatcherChangeTypes

要監視的 WatcherChangeTypes

傳回

WaitForChangedResult,含有發生之變更的特定資訊。

備註

此方法會無限期等候,直到發生第一次變更,然後傳回。 這與搭配 timeout 參數設定為 -1 的 使用 WaitForChanged 相同。

注意

這個方法允許叫用事件處理常式來回應檔案變更,即使 EnableRaisingEvents 屬性設定為 false

在某些系統中, FileSystemWatcher 會使用簡短的 8.3 檔案名格式來報告檔案的變更。 例如,「LongFileName.LongExtension」 的變更可能會回報為 「LongFi~」。Lon」。

另請參閱

適用於

WaitForChanged(WatcherChangeTypes, Int32)

來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs

提供您想要監視的變更類型和逾時前的等候時間 (以毫秒計),同步方法會傳回含有發生的變更之特定資訊的結構。

public:
 System::IO::WaitForChangedResult WaitForChanged(System::IO::WatcherChangeTypes changeType, int timeout);
public System.IO.WaitForChangedResult WaitForChanged (System.IO.WatcherChangeTypes changeType, int timeout);
member this.WaitForChanged : System.IO.WatcherChangeTypes * int -> System.IO.WaitForChangedResult
Public Function WaitForChanged (changeType As WatcherChangeTypes, timeout As Integer) As WaitForChangedResult

參數

changeType
WatcherChangeTypes

要監視的 WatcherChangeTypes

timeout
Int32

逾時之前的等候時間 (單位為毫秒)。

傳回

WaitForChangedResult,含有發生之變更的特定資訊。

備註

這個方法會等到發生變更或逾時為止。參數的 -1 timeout 值表示無限期等候。

注意

這個方法允許叫用事件處理常式來回應檔案變更,即使 EnableRaisingEvents 屬性設定為 false

在某些系統中, FileSystemWatcher 會使用簡短的 8.3 檔案名格式來報告檔案的變更。 例如,「LongFileName.LongExtension」 的變更可能會回報為 「LongFi~」。Lon」。

另請參閱

適用於

WaitForChanged(WatcherChangeTypes, TimeSpan)

來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs
來源:
FileSystemWatcher.cs

根據要監視的變更類型,以同步方式傳回結構,其中包含所發生變更的特定資訊。

public:
 System::IO::WaitForChangedResult WaitForChanged(System::IO::WatcherChangeTypes changeType, TimeSpan timeout);
public System.IO.WaitForChangedResult WaitForChanged (System.IO.WatcherChangeTypes changeType, TimeSpan timeout);
member this.WaitForChanged : System.IO.WatcherChangeTypes * TimeSpan -> System.IO.WaitForChangedResult
Public Function WaitForChanged (changeType As WatcherChangeTypes, timeout As TimeSpan) As WaitForChangedResult

參數

changeType
WatcherChangeTypes

要監視的 WatcherChangeTypes

timeout
TimeSpan

逾時之前要等候的時間量。

傳回

WaitForChangedResult,含有發生之變更的特定資訊。

備註

請參閱 WaitForChanged(WatcherChangeTypes, Int32) 備註。

適用於