Skip to content

DiGi.Core.IO.FileWatcher.Classes

github-actions[bot] edited this page Jul 15, 2026 · 2 revisions

DiGi.Core.IO.FileWatcher.Classes Namespace

Classes

ConfigurationFileWatcher Class

Watches a configuration file for changes and provides access to its content.

public class ConfigurationFileWatcher : DiGi.Core.IO.FileWatcher.Classes.FileWatcher

Inheritance System.ObjectFileWatcher → ConfigurationFileWatcher

Constructors

ConfigurationFileWatcher(string, double, Encoding) Constructor

Initializes a new instance of the ConfigurationFileWatcher class.

public ConfigurationFileWatcher(string path, double interval=5000.0, System.Text.Encoding? encoding=null);

Parameters

path System.String

The path to the configuration file to watch.

interval System.Double

The interval in milliseconds between checks for changes.

encoding System.Text.Encoding

The encoding to use when reading the file.

Properties

ConfigurationFileWatcher.ConfigurationFile Property

Gets the configuration file associated with this watcher.

public DiGi.Core.Classes.ConfigurationFile ConfigurationFile { get; }

Property Value

DiGi.Core.Classes.ConfigurationFile

Operators

ConfigurationFileWatcher.implicit operator ConfigurationFile(ConfigurationFileWatcher) Operator

Implicitly converts a ConfigurationFileWatcher instance to its associated ConfigurationFile.

public static DiGi.Core.Classes.ConfigurationFile? implicit operator DiGi.Core.Classes.ConfigurationFile?(DiGi.Core.IO.FileWatcher.Classes.ConfigurationFileWatcher? configurationFileWatcher);

Parameters

configurationFileWatcher ConfigurationFileWatcher

The ConfigurationFileWatcher instance to convert.

Returns

DiGi.Core.Classes.ConfigurationFile
The ConfigurationFile associated with the watcher, or null if the watcher is null.

FileWatcher Class

Monitors any file and reloads its binary content only if the hash has changed.

public class FileWatcher : System.IDisposable, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject

Inheritance System.Object → FileWatcher

Derived
ConfigurationFileWatcher
FileWatcher<TFile>

Implements System.IDisposable, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject

Constructors

FileWatcher(string, double) Constructor

Initializes a new instance of the FileWatcher class to monitor changes to the specified file at a given interval.

public FileWatcher(string path, double interval=5000.0);

Parameters

path System.String

The full path to the file to be monitored. The file must exist at the time of initialization.

interval System.Double

The interval, in milliseconds, at which the file is checked for changes. The default is 5000 milliseconds.

Exceptions

System.IO.FileNotFoundException
Thrown if the file specified by path does not exist.

Properties

FileWatcher.Bytes Property

Gets the raw bytes of the file content.

public byte[]? Bytes { get; }

Property Value

System.Byte[]

FileWatcher.Interval Property

Gets or sets the interval in milliseconds between checks for file changes.

public double Interval { get; set; }

Property Value

System.Double

FileWatcher.Path Property

Gets the path to the file being watched.

public string Path { get; }

Property Value

System.String

Methods

FileWatcher.Dispose() Method

Releases all resources used by the watcher.

public void Dispose();

Implements Dispose()

FileWatcher.GetLines(Encoding) Method

Reads the content of the file as an array of strings.

public string[]? GetLines(System.Text.Encoding? encoding=null);

Parameters

encoding System.Text.Encoding

The encoding to use when reading the file.

Returns

System.String[]
An array of strings containing the lines of the file.

FileWatcher.GetString(Encoding) Method

Reads the content of the file as a single string.

public string GetString(System.Text.Encoding? encoding=null);

Parameters

encoding System.Text.Encoding

The encoding to use when reading the file.

Returns

System.String
The content of the file as a string.

FileWatcher<TFile> Class

Provides a base implementation for watching a file for changes.

public abstract class FileWatcher<TFile> : DiGi.Core.IO.FileWatcher.Classes.FileWatcher
    where TFile : DiGi.Core.IO.File.Interfaces.IFile

Type parameters

TFile

The type of the file being watched.

Inheritance System.ObjectFileWatcher → FileWatcher<TFile>

Constructors

FileWatcher(string, double) Constructor

Initializes a new instance of the FileWatcher class.

public FileWatcher(string path, double interval=60000.0);

Parameters

path System.String

The path to the file to watch.

interval System.Double

The interval in milliseconds between checks for changes.

Properties

FileWatcher<TFile>.File Property

Gets the file object being watched.

public TFile? File { get; }

Property Value

TFile

Clone this wiki locally