static void Main(string[] args) { using var watcher = new FileSystemWatcher( @"T:\Workspace\Personal\TFW\TFW.WebAPI", "appsettings.json") .IncludeSubdirs(false) .NotifyFilter(NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size); watcher.Changed += Watcher_Changed; watcher.Start(); Console.WriteLine("Press enter to exit."); Console.ReadLine(); }
public static FileSystemWatcher Watch(string path, string filter = null) { var fsw = new FileSystemWatcher(path, filter); return fsw.Start(); }