private void ProcessFileIfCreatedAndReady(string filePath) { if (creatingFileList.StartReadyVerifing(filePath)) { if (FileIsReady(filePath)) { creatingFileList.RemoveFilePath(filePath); Task.Factory.StartNew(() => { NewFileCreated?.Invoke(filePath); }); } else { creatingFileList.EndReadyVerifing(filePath); } } if (creatingFileList.Contains(filePath)) { Task.Factory.StartNew(() => { Thread.Sleep(5); ProcessFileIfCreatedAndReady(filePath); }); } }
private void FileSystemWatcher_FileCreated(object sender, FileSystemEventArgs e) { FileInfo file = new FileInfo(e.FullPath); if ((file.Attributes & (FileAttributes.Hidden | FileAttributes.Temporary | FileAttributes.System)) == 0 && file.Extension != ".tmp") { NewFileCreated?.Invoke(sender, e); } }