//0.13: Added HasParent /// <summary> /// Return whether parent directory contain child directory. /// Aware Library, UserFiles and Public directory too. /// </summary> /// <param name="child"></param> /// <param name="parent"></param> /// <returns></returns> public static bool HasParent(FileSystemInfoEx child, DirectoryInfoEx parent) { if (parent == null) { //if (Debugger.IsAttached) // Debugger.Break(); return(false); } //::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\Music.library-ms if (parent.FullName.StartsWith(IOTools.IID_Library) && parent.FullName.EndsWith(".library-ms")) { //Reverse foreach (DirectoryInfoEx subDir in parent.GetDirectories()) { if (subDir.Equals(child) || HasParent(child, subDir)) { return(true); } } return(false); } else { if (child.FullName.StartsWith(parent.FullName, StringComparison.InvariantCultureIgnoreCase)) { return(true); } if (child.FullName.StartsWith(IID_UserFiles) || child.FullName.StartsWith(IID_Public)) { return(false); } FileSystemInfoEx current = child.Parent; while (current != null && !parent.Equals(current)) { current = current.Parent; } return(current != null); } }
public static string[] GetDirectories(string path) { DirectoryInfoEx rootDir = new DirectoryInfoEx(path); return FSListToStringList(rootDir.GetDirectories()); }
public static string[] GetDirectories(string path) { DirectoryInfoEx rootDir = new DirectoryInfoEx(path); return(FSListToStringList(rootDir.GetDirectories())); }
//0.13: Added HasParent /// <summary> /// Return whether parent directory contain child directory. /// Aware Library, UserFiles and Public directory too. /// </summary> /// <param name="child"></param> /// <param name="parent"></param> /// <returns></returns> public static bool HasParent(FileSystemInfoEx child, DirectoryInfoEx parent) { if (parent == null) { //if (Debugger.IsAttached) // Debugger.Break(); return false; } //::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\Music.library-ms if (parent.FullName.StartsWith(IOTools.IID_Library) && parent.FullName.EndsWith(".library-ms")) { //Reverse foreach (DirectoryInfoEx subDir in parent.GetDirectories()) if (subDir.Equals(child) || HasParent(child, subDir)) return true; return false; } else { if (child.FullName.StartsWith(parent.FullName.TrimEnd('\\') + "\\", StringComparison.InvariantCultureIgnoreCase)) return true; if (child.FullName.StartsWith(IID_UserFiles) || child.FullName.StartsWith(IID_Public)) return false; FileSystemInfoEx current = child.Parent; while (current != null && !parent.Equals(current)) current = current.Parent; return (current != null); } }