用FileSystemWatch监视一个*.txt文件的改变,用Notepad打开修改后保存时
Changed事件被触发了两次!怎么才能让它出现一次?
不用bool值来判断!FileSystemWatch的NotifyFilter设置为LastWrite 

解决方案 »

  1.   

    this.fileSystemWatcher1.Filter = "*.txt";
    this.fileSystemWatcher1.NotifyFilter = System.IO.NotifyFilters.LastWrite;
      

  2.   

    Changed 事件的第二个参数 FileSystemEventArgs e用 e.ChangeType 判断
      

  3.   

    我用e.ChangeType  打印出来也是两个changed事件
      

  4.   

    [this.fileSystemWatcher1.Filter = "*.txt";]和[Form1.fileSystemWatcher1.Filter = "*.txt";]是一样的吧!!!这种设置方法我知道,只是不知道怎么去屏蔽掉那changed事件中的一个???
      

  5.   

    lastwrite本身就会触发2次change的
      

  6.   

    难道真的没什么好的办法可以控制它出现一次吗?
    真的要放弃用lastwrite码?