/// <inheritdoc/> public override void Execute(object parameter) { CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; if (parameter != null && parameter is string stringParameter) { if (Directory.Exists(stringParameter)) { dialog.DefaultDirectory = stringParameter; } } CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { string filePath = dialog.FileName + "\\"; data = Directory.Exists(filePath) ? filePath : string.Empty; if (condition != null && condition.ConditionFailed(data)) { ThrowError(ErrorSeverityEnum.Error, condition.ErrorMessage); return; } ExecutionDone(); } }
/// <inheritdoc/> public override void Execute(object parameter) { if (!CanExecute(parameter, true)) { return; } if (parameter != null && parameter is string targetFolder) { if (targetCondition != null && targetCondition.ConditionFailed(targetFolder)) { return; } Directory.CreateDirectory(targetFolder); string[] files = Directory.GetFiles(sourceFolder); foreach (string file in files) { if (!File.Exists(file)) { continue; } if (sourceCondition != null && sourceCondition.ConditionFailed(file)) { continue; } FileInfo fileInfo = new FileInfo(file); string targetFile = Path.Combine(targetFolder, fileInfo.Name); File.Copy(file, targetFile); if (File.Exists(targetFile)) { File.Delete(file); } } if ( Directory.Exists(sourceFolder) && Directory.GetFiles(sourceFolder).Length == 0 && Directory.GetDirectories(sourceFolder).Length == 0 ) { Directory.Delete(sourceFolder); } sourceFolder = targetFolder; } }
/// <inheritdoc/> public override void Execute(object parameter) { if (!CanExecute(parameter)) { return; } if (condition != null && condition.ConditionFailed(parameter)) { return; } window.Dispatcher.Invoke( new SetWindowStateCallback(SetWindowState), new object[] { window, WindowState.Minimized } ); }