/// <summary> /// get sub shell items for path /// </summary> /// <param name="path"></param> /// <returns></returns> public static DataSourceShell GetShellItem(string path) { if (!CommonProvider.Directory.Exists(path)) { return(null); } try { DataSourceShell shell = new DataSourceShell(); var items = shell.GetSubItems(); var rootNode = items.FirstOrDefault(o => o.ParsingName == CommonProvider.ComputerParseName); bool isStop = false; DataSourceShell targetShell = null; while (!isStop) { var shells = rootNode.GetSubItems(); targetShell = shells.FirstOrDefault(o => CommonProvider.CheckIsTopLevel(o.Path, path)); if (targetShell.Path.IsPathEqual(path)) { isStop = true; } rootNode = targetShell; } return(targetShell); } catch (Exception ex) { LogHelper.Debug(ex.Message); return(null); } }
/// <summary> /// get path from shell /// </summary> /// <param name="shell"></param> static void getSubPathByRecursion(DataSourceShell shell) { var items = shell.GetSubItems(); foreach (var item in items) { if (item.Path.IsNullOrEmpty()) { getSubPathByRecursion(item); } else { shellSubPaths.Add(item.Path); } } }