/// <summary> /// Populate the Items of the specified BreadcrumbItem with the sub folders if necassary. /// </summary> /// <param name="item"></param> private static void PopulateFolders(BreadcrumbItem item) { BreadcrumbBar bar = item.BreadcrumbBar; string path = bar.PathFromBreadcrumbItem(item); string trace = item.TraceValue; if (trace.Equals("Computer")) { string[] dirs = System.IO.Directory.GetLogicalDrives(); foreach (string s in dirs) { //string dir = s; //if (s.EndsWith(bar.SeparatorString)) dir = s.Remove(s.Length - bar.SeparatorString.Length, bar.SeparatorString.Length); //FolderItem fi = new FolderItem(); //fi.Folder = dir; //item.Items.Add(fi); } } else { try { if (item.Data is SessionItemViewModel) { foreach (var row in (item.Data as SessionItemViewModel).Children) { item.Items.Add(row as SessionItemViewModel); } } } catch { } } }
/// <summary> /// Gets a list of FolderItems that are the subfolders of the specified BreadcrumbItem. /// </summary> private static List <FolderItem> GetFolderItemsFromBreadcrumb(BreadcrumbItem item) { BreadcrumbBar bar = item.BreadcrumbBar; string path = bar.PathFromBreadcrumbItem(item); string trace = item.TraceValue; string[] subFolders; if (trace.Equals("Computer")) { subFolders = GetDrives(bar.SeparatorString).ToArray(); } else { try { subFolders = (from dir in System.IO.Directory.GetDirectories(path + "\\") select System.IO.Path.GetFileName(dir)).ToArray(); } catch { //maybe we don't have access! subFolders = new string[] { }; } } List <FolderItem> folderItems = (from folder in subFolders orderby folder select new FolderItem { Folder = folder }).ToList(); return(folderItems); }
/// <summary> /// Populate the Items of the specified BreadcrumbItem with the sub folders if necassary. /// </summary> /// <param name="item"></param> private static void PopulateFolders(BreadcrumbItem item) { BreadcrumbBar bar = item.BreadcrumbBar; string path = bar.PathFromBreadcrumbItem(item); string trace = item.TraceValue; if (trace.Equals("Computer")) { string[] dirs = System.IO.Directory.GetLogicalDrives(); foreach (string s in dirs) { string dir = s; if (s.EndsWith(bar.SeparatorString)) { dir = s.Remove(s.Length - bar.SeparatorString.Length, bar.SeparatorString.Length); } FolderItem fi = new FolderItem(); fi.Folder = dir; item.Items.Add(fi); } } else { try { string[] paths = System.IO.Directory.GetDirectories(path + "\\"); foreach (string s in paths) { string file = System.IO.Path.GetFileName(s); FolderItem fi = new FolderItem(); fi.Folder = file; item.Items.Add(fi); } } catch { } } }