/// <summary> /// Handle files dropped in main form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_DragDrop(object sender, DragEventArgs e) { var dataDrop = (string[])e.Data.GetData(DataFormats.FileDrop); var files = new List <string>(); var folders = new List <string>(); foreach (var dataItem in dataDrop) { FileAttributes fAttributes = File.GetAttributes(@dataItem); if ((fAttributes & FileAttributes.Directory) == FileAttributes.Directory) { folders.Add(dataItem); } else { files.Add(dataItem); } } if (folders.Count > 0) { RecursiveFileReader rfr = new RecursiveFileReader(); foreach (var folder in folders) { files.AddRange(rfr.GetFiles(folder, Settings.Default.FolderDepth)); } } var tabFiles = files.Select(file => new TabFile { File = file, Name = Guid.NewGuid().ToString(), TabName = file }).ToList(); SetFile(tabFiles); }
/// <summary> /// Open a folder and Recursive get files from folder /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void openFolderToolStripMenuItem_Click(object sender, EventArgs e) { var files = new List <string>(); var result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { RecursiveFileReader rfr = new RecursiveFileReader(); files.AddRange(rfr.GetFiles(folderBrowserDialog1.SelectedPath, Settings.Default.FolderDepth)); } var tabFiles = files.Select(file => new TabFile { File = file, Name = Guid.NewGuid().ToString(), TabName = file }).ToList(); SetFile(tabFiles); }