示例#1
0
        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();
        }
示例#2
0
 public static FileSystemWatcher Watch(string path, string filter = null)
 {
     var fsw = new FileSystemWatcher(path, filter);
     return fsw.Start();
 }