private void CleanupFolder() { if (string.IsNullOrWhiteSpace(InputFolder) || !Directory.Exists(InputFolder)) { MessageBox.Show("Invalid folder. Please provide a valid input folder"); } var files = Directory.GetFiles(InputFolder, "*.txt"); foreach (var file in files) { var doc = new DocumentViewModel(); doc.LoadDocument(file); doc.JoinLines(); doc.Cleanup(true); doc.SaveDocument(); } }