private void ProcessFiles(object cmd) { ChoAppSettings appSettings = cmd as ChoAppSettings; // cmd.ToString(); if (appSettings == null) { return; } try { IsRunning = true; _roboCopyManager = new ChoRoboCopyManager(); _roboCopyManager.Status += (sender, e) => SetStatusMsg(e.Message); _roboCopyManager.AppStatus += (sender, e) => UpdateStatus(e.Message, e.Tag.ToNString()); _roboCopyManager.Process(appSettings.RoboCopyFilePath, appSettings.GetCmdLineParams(), appSettings); } catch (ThreadAbortException) { } catch (Exception ex) { SetStatusMsg(ex.ToString()); } finally { IsRunning = false; _roboCopyManager = null; } }
public void StartFileCopy(string sourceDirectory = null, string destDirectory = null) { try { ChoAppSettings appSettings = new ChoAppSettings(); if (!SettingsFilePath.IsNullOrWhiteSpace()) { if (!File.Exists(SettingsFilePath)) { throw new ArgumentException("Can't find '{0}' settings file.".FormatString(SettingsFilePath)); } appSettings.LoadXml(File.ReadAllText(SettingsFilePath)); } ChoConsole.WriteLine(); ChoRoboCopyManager _roboCopyManager = new ChoRoboCopyManager(SettingsFilePath); _roboCopyManager.Status += (sender, e) => { ChoTrace.Write(e.Message); ChoConsole.Write(e.Message, ConsoleColor.Yellow); }; _roboCopyManager.AppStatus += (sender, e) => { ChoTrace.Write(e.Message); ChoConsole.Write(e.Message, ConsoleColor.Yellow); }; _roboCopyManager.Process(appSettings.RoboCopyFilePath, appSettings.GetCmdLineParams(), appSettings, true); } catch (ThreadAbortException) { Console.WriteLine("RoboCopy operation cancelled by user."); } catch (Exception ex) { Console.WriteLine("RoboCopy operation failed." + Environment.NewLine + ChoApplicationException.ToString(ex)); } }