private void ResultReady(object sender, FileMoveResult result) { if (result == null) { RunAfterTestsRoutines(); return; } var status = result.exception == null ? "OK" : "Error"; var line = new ListViewItem { BackColor = result.exception == null ? Color.Green : Color.Red, Text = $"{Path.GetFileName(result.SourcePath)}", ToolTipText = result.exception == null ? result.TargetPath : TryToGetUserFriendlyExceptionDescription(result.exception) }; lVLog.Items.Add(line); progressBar.Value += result.fileSizeInPercents; }
public FileMoveResult Start() { var result = new FileMoveResult { SourcePath = itemPath }; try { var target = GetTargetPath(itemPath, destinationFolder); result.TargetPath = target; if (Directory.Exists(itemPath)) //if is directory { string uniqueTargetName = MakeFileNameUnique(target); AddLocks(itemPath, sourceLocks); try { MoveDirectory(itemPath, uniqueTargetName); } catch (Exception ex) { MoveDirectory(uniqueTargetName, itemPath, false); throw; } } else if (File.Exists(itemPath)) //if is file { MoveFile(itemPath, target); } else { throw new FileNotFoundException("Source file was not found.", itemPath); } } catch (Exception ex) { result.exception = ex; return(result); } return(result); }
public FileMoveResult Start() { var result = new FileMoveResult { SourcePath= itemPath }; try { var target = GetTargetPath(itemPath, destinationFolder); result.TargetPath = target; if (Directory.Exists(itemPath)) //if is directory { string uniqueTargetName = MakeFileNameUnique(target); AddLocks(itemPath,sourceLocks); try { MoveDirectory(itemPath, uniqueTargetName); } catch (Exception ex) { MoveDirectory(uniqueTargetName,itemPath,false); throw; } } else if (File.Exists(itemPath)) //if is file { MoveFile(itemPath, target); } else { throw new FileNotFoundException("Source file was not found.", itemPath); } } catch (Exception ex) { result.exception = ex; return result; } return result; }
private void OnResultReady(FileMoveResult result) { ResultReady?.Invoke(typeof(Desktop), result); }
private void ResultReady(object sender, FileMoveResult result) { if (result==null) { RunAfterTestsRoutines(); return; } var status = result.exception == null ? "OK" : "Error"; var line = new ListViewItem { BackColor = result.exception == null ? Color.Green : Color.Red, Text = $"{Path.GetFileName(result.SourcePath)}: {status}", ToolTipText = result.exception == null ? result.TargetPath : TryToGetUserFriendlyExceptionDescription(result.exception) }; lVLog.Items.Add(line); progressBar.Value += result.fileSizeInPercents; }
private void OnResultReady(FileMoveResult result) { ResultReady?.Invoke(typeof(Desktop), result); }