FileSystemWatcher.WaitForChanged Method

Definition

A synchronous method that returns a structure that contains specific information on the change that occurred.

Overloads

WaitForChanged(WatcherChangeTypes)

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.

WaitForChanged(WatcherChangeTypes, Int32)

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.

WaitForChanged(WatcherChangeTypes, TimeSpan)

Synchronously returns a structure that contains specific information on the change that occurred, given the type of change to monitor.

WaitForChanged(WatcherChangeTypes)

Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs

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.

C#
public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeTypes changeType);

Parameters

changeType
WatcherChangeTypes

The WatcherChangeTypes to watch for.

Returns

A WaitForChangedResult that contains specific information on the change that occurred.

Remarks

This method waits indefinitely until the first change occurs and then returns. This is the same as using WaitForChanged with the timeout parameter set to -1.

Note

This method allows an event handler to be invoked to respond to file changes even if the EnableRaisingEvents property is set to false.

In some systems, FileSystemWatcher reports changes to files using the short 8.3 file name format. For example, a change to "LongFileName.LongExtension" could be reported as "LongFi~.Lon".

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WaitForChanged(WatcherChangeTypes, Int32)

Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs

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.

C#
public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeTypes changeType, int timeout);

Parameters

changeType
WatcherChangeTypes

The WatcherChangeTypes to watch for.

timeout
Int32

The time (in milliseconds) to wait before timing out.

Returns

A WaitForChangedResult that contains specific information on the change that occurred.

Remarks

This method waits until a change occurs or it has timed out. A value of -1 for the timeout parameter means wait indefinitely.

Note

This method allows an event handler to be invoked to respond to file changes even if the EnableRaisingEvents property is set to false.

In some systems, FileSystemWatcher reports changes to files using the short 8.3 file name format. For example, a change to "LongFileName.LongExtension" could be reported as "LongFi~.Lon".

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WaitForChanged(WatcherChangeTypes, TimeSpan)

Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs
Source:
FileSystemWatcher.cs

Synchronously returns a structure that contains specific information on the change that occurred, given the type of change to monitor.

C#
public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeTypes changeType, TimeSpan timeout);

Parameters

changeType
WatcherChangeTypes

The WatcherChangeTypes to watch for.

timeout
TimeSpan

The amount of time to wait before timing out.

Returns

A WaitForChangedResult that contains specific information on the change that occurred.

Remarks

See WaitForChanged(WatcherChangeTypes, Int32) remarks.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10