private void LoadFolders() { try { if (Folders.Count > 0) return; string[] dirs = null; string fullPath = Path.Combine(FolderPath, FolderName); var bDrive = FolderName.Contains(':'); if (FolderName.Contains(':'))//This is a drive { fullPath = string.Concat(FolderName, @"\"); } else { fullPath = FolderPath; } dirs = Directory.GetDirectories(fullPath); Folders.Clear(); foreach (string dir in dirs) { try { DirectoryInfo di = new DirectoryInfo(dir); // create the sub-structure only if this is not a hidden directory //TODO hack SORT OUT THIS WAITING BUSINESS - For some reason this path doesn't answer di.Attributes for 15 minutes?!? if (dir.StartsWith("P:\\USAUS")) continue; //WORK AROUND Line below - (when a full path is pasted into the text box - only expand the actual path (or as much of it as possible) if (!(Root.SelectedFolder.StartsWith(dir) || System.IO.Path.GetDirectoryName(dir) == (Root.SelectedFolder + (bDrive ? @"\" : "")))) continue; if ((di.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { Folders.Add(new FolderViewModel { Root = this.Root, FolderName = Path.GetFileName(dir), FolderPath = Path.GetFullPath(dir), FolderIcon = "Images\\FolderClosed.png" }); } } catch (UnauthorizedAccessException ae) { Console.WriteLine(ae.Message); } catch (Exception e) { Console.WriteLine(e.Message); } } if (FolderName.Contains(":")) FolderIcon = "Images\\HardDisk.ico"; } catch (UnauthorizedAccessException ae) { Console.WriteLine(ae.Message); } catch (IOException ie) { Console.WriteLine(ie.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)