GH_FileWatcher

References
Provides easy mechanisms to monitor changes to the local File System.

Properties

Active

#
public bool Active { get; set; }
Gets or sets the active flag on this watcher.

Buffer

#
public TimeSpan Buffer { get; set; }
Gets or sets the time during which events are buffered. If multiple events for the same file occur within the buffered timespan, they will be merged into one event.

InvokeOnDefaultThread

#
public bool InvokeOnDefaultThread { get; set; }
Gets or sets invoke behaviour for events. If true, then the event delegate is called via the Grasshopper main UI thread. This is almost always what you need.

IsDisposed

#
public bool IsDisposed { get; }

Path

#
public string Path { get; }
Gets the file or folder path currently being watched.

Methods

CreateDirectoryWatcher

#
public static GH_FileWatcher CreateDirectoryWatcher(string folderPath, string filter, GH_FileWatcherEvents events, FileChanged delegate)
Create a new FileSystem Watcher object aimed at a specific file.
folderPath (string)Folder to watch.
filter (string)Filter string for filenames.
events (GH_FileWatcherEvents)Events to watch for.
delegate (GH_FileWatcher.FileChanged)Callback delegate.
A new filewatcher aimed at the specified folder.

CreateDirectoryWatcher

#
public static GH_FileWatcher CreateDirectoryWatcher(string folderPath, string filter, GH_FileWatcherEvents events, FileChangedSimple delegate)
Create a new FileSystem Watcher object aimed at a specific file.
folderPath (string)Folder to watch.
filter (string)Filter string for filenames.
events (GH_FileWatcherEvents)Events to watch for.
delegate (GH_FileWatcher.FileChangedSimple)Callback delegate.
A new filewatcher aimed at the specified folder.

CreateFileWatcher

#
public static GH_FileWatcher CreateFileWatcher(string filePath, GH_FileWatcherEvents events, FileChanged delegate)
Create a new FileSystem Watcher object aimed at a specific file.
filePath (string)File to watch.
events (GH_FileWatcherEvents)Events to watch for.
delegate (GH_FileWatcher.FileChanged)Callback delegate.
A new filewatcher aimed at the specified file.

CreateFileWatcher

#
public static GH_FileWatcher CreateFileWatcher(string filePath, GH_FileWatcherEvents events, FileChangedSimple delegate)
Create a new FileSystem Watcher object aimed at a specific file.
filePath (string)File to watch.
events (GH_FileWatcherEvents)Events to watch for.
delegate (GH_FileWatcher.FileChangedSimple)Callback delegate.
A new filewatcher aimed at the specified file.

Dispose

#
public void Dispose()

Dispose

#
protected virtual void Dispose(bool disposing)
disposing (bool)

SetCustomUIThread

#
public void SetCustomUIThread(Control target)
If you want to override the default Invoke behaviour, you must set InvokeOnDefaultThread to False and supply either a custom Control or a Form.
target (Control)GUI target object which will be used for Invoking File System Events.

SetCustomUIThread

#
public void SetCustomUIThread(Form target)
If you want to override the default Invoke behaviour, you must set InvokeOnDefaultThread to False and supply either a custom Control or a Form.
target (Form)GUI target object which will be used for Invoking File System Events.