private static Folder ImportFromFolder(string selectedPath) { var rootDirectory = selectedPath; var rootFolder = new Folder(); rootFolder.Initialize(); rootFolder.Name = Path.GetFileNameWithoutExtension(rootDirectory); var directories = Directory.GetDirectories(rootDirectory); List<string> images; foreach (var directory in directories) { var folder = ImportFromFolder(directory); rootFolder.AddChild(folder); } images = Directory.GetFiles(rootDirectory, "*.png", SearchOption.TopDirectoryOnly).ToList(); images.AddRange(Directory.GetFiles(rootDirectory, "*.gif", SearchOption.TopDirectoryOnly)); foreach (var filename in images) { var imageData = CreateFromFilename(filename); rootFolder.AddChild(imageData); } return rootFolder; }
public static void ImportFromExistingDirectoryDialog(Folder folder) { var dialog = new FolderBrowserDialog { RootFolder = Environment.SpecialFolder.Desktop, ShowNewFolderButton = false, SelectedPath = Settings.Default.LastFolderBrowsed }; if (dialog.ShowDialog() == DialogResult.OK) { Settings.Default.LastFolderBrowsed = dialog.SelectedPath; Settings.Default.Save(); var rootFolder = ImportFromFolder(dialog.SelectedPath); folder.AddChild(rootFolder); } }