private void Copy(object sender, EventArgs e) { if (txtFolders.Lines.Length == 0 || txtRoutes.Lines.Length == 0) { lblResult.Text = VOIDFIELDS; return; } if (txtExcludes.Lines.Length > 0 && txtExcludes.Lines[0].Split(';').Any(ex => ex.IndexOfAny(".".ToCharArray()) != 0)) { lblResult.Text = INVALIDEXT; return; } lblResult.Text = "WORKING..."; Settings settings = new Settings(); settings.Folders = new List <string>(txtFolders.Lines); settings.ReplaceFolder = new List <string>(txtRoutes.Lines); settings.ExcludedExt = new List <string>(txtExcludes.Lines[0].Split(';')); try { List <ProcessedFile> files = RecursiveFileProcessor.Process(settings); StringBuilder clipData = new StringBuilder(); files.ForEach(f => clipData.AppendLine(f.Path + "\t" + "\t" + "\t" + f.Extension)); Clipboard.SetDataObject(clipData.ToString(), true); lblResult.Text = "SUCCESS!"; } catch (Exception) { lblResult.Text = "ERROR!"; } }
static void Main(string[] args) { StringBuilder clipData = new StringBuilder(); try { ReadConfig(out Settings data); List <ProcessedFile> files = RecursiveFileProcessor.Process(data); //files.ForEach(f => Console.WriteLine(f.Path)); files.ForEach(f => clipData.AppendLine(f.Path + "\t" + "\t" + "\t" + f.Extension)); Clipboard.SetDataObject(clipData.ToString(), true); } catch (ArgumentNullException ex) { clipData.AppendLine(ex.Message); Clipboard.SetDataObject(clipData.ToString(), true); } catch (Exception ex) { Console.WriteLine(ex.Message); } }