示例#1
0
        public static void Run()
        {
            // Create a new FileSystemWatcher and set its properties.
            // Params: Path, and filter
            using (var watcher =
                       new FileSystemWatcher(Dir, "*.pdf"))
            {
                watcher.InternalBufferSize = 8192000;
                // To watch SubDirectories
                watcher.IncludeSubdirectories = true;

                var handler = new FswHandler();

                // Add event handlers.
                watcher.Created += handler.OnCreated;
                watcher.Renamed += handler.OnCreated;
                watcher.Changed += handler.OnCreated;

                // Begin watching.
                watcher.EnableRaisingEvents = true;

                // Wait for the user to quit the program.
                Console.WriteLine("Press 'q' to quit the sample.");
                while (Console.Read() != 'q')
                {
                    ;
                }
            }
        }
示例#2
0
			static void Main()
			{
				FileSystemWatcher FSW = new FileSystemWatcher("c:\\", "*.cs");
				FswHandler Handler = new FswHandler();
				FSW.Changed += Handler.OnEvent;
				FSW.Created += Handler.OnEvent;
				FSW.Deleted += Handler.OnEvent;
				FSW.Renamed += Handler.OnEvent;
				FSW.EnableRaisingEvents = true;
				System.Threading.Thread.Sleep(555000);
				// change the file manually to see which events are fired
				FSW.EnableRaisingEvents = false;
			}