public void FileAdded(string file) { if (FileAddedEvent != null) { FileAddedEvent.Invoke(file); } }
private void ProcessFile(string path) { var fiSource = new FileInfo(path); Logging.Log($"ADD: {path}", this, LoggingType.Status, 3); var pathTemp = Path.Combine(_pathTemp, fiSource.Name); var pathTempNew = Path.Combine(_pathTemp, fiSource.Name + "processed"); var relativeSrc = fiSource.DirectoryName.Substring(_pathPictures.Length); if (relativeSrc.StartsWith(@"\")) { relativeSrc = relativeSrc.Substring(1); } var pathDest = Path.Combine(_pathDestination, relativeSrc); try { //file needs to be processed. copy the file to a local dir _fileOperation.FileCopy(fiSource.FullName, pathTemp); ImageUtil.ResizeFile(pathTemp, pathTempNew, Settings.Default.LongSideLength); _fileOperation.CreateDirectory(pathDest); pathDest = Path.Combine(pathDest, fiSource.Name); _fileOperation.FileCopy(pathTempNew, pathDest); } finally { if (File.Exists(pathTemp)) { File.Delete(pathTemp); } if (File.Exists(pathTempNew)) { File.Delete(pathTempNew); } } FileAddedEvent?.Invoke(this, ++_filesAdded); }
/// <summary> /// イベントを発生させる /// </summary> /// <param name="e"></param> protected virtual void OnFileAdded(FileAddedEventArgs e) { FileAddedEvent?.Invoke(this, e); }