解决方案 »

  1.   

    不用这么复杂吧?
     FileSystemWatcher mywatcher = null;
            public void watch()
            {            mywatcher = new FileSystemWatcher();
                mywatcher.Path = @"F:\doc";
                //mywatcher.Path=@"E:\zxj";
                mywatcher.NotifyFilter = NotifyFilters.LastWrite;
                //mywatcher.Filter = "test.txt";
                mywatcher.Changed += new FileSystemEventHandler(OnChanged);
                mywatcher.EnableRaisingEvents = true;
            }        private void OnChanged(object source, FileSystemEventArgs e)
            {
                mywatcher.EnableRaisingEvents = false;
                if (e.ChangeType == WatcherChangeTypes.Changed)
                {
                    MessageBox.Show("File is Modified!");
                }
                mywatcher.EnableRaisingEvents = true;
                mywatcher.Changed -= new FileSystemEventHandler(OnChanged);
            }
    这样好像就可以了啊。