// Define the event handlers. private void OnChanged(object source, FileSystemEventArgs e) { //if ((!(LastChangeFileName == e.Name)) ) if ((!(LastChangeFileName == e.Name)) && (!IsTmpFile(e.Name))) { sendSync1=new SendSync("Send", hostName, e.FullPath,path); LastChangeFileName = e.Name; // 100ms 后取消对重复文件改变的屏蔽 Thread th = new Thread(new ThreadStart( delegate() { Thread.Sleep(100); LastChangeFileName = ""; } )); th.Start(); } }
private void OnDeleted(object source, FileSystemEventArgs e) { if (!IsTmpFile(e.Name)) { sendSync2 = new SendSync("Delete", hostName, e.FullPath, path); } }
private void OnRenamed(object source, RenamedEventArgs e) { if (!IsTmpFile(e.Name)) { sendSync3 = new SendSync("Delete", hostName, e.OldFullPath, path); sendSync4 = new SendSync("Send", hostName, e.FullPath, path); } // Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath); }