public static DirectoryNode FromPath(string path, DelayedStreamCache cache, FileAccess access = FileAccess.Read, FileShare share = FileShare.Read) { DirectoryInfo dir = new DirectoryInfo(path); DirectoryNode node = new DirectoryNode(dir.Name); FromPath(node, path, cache, access, share); return(node); }
protected static void FromPath(DirectoryNode parent, string path, DelayedStreamCache cache, FileAccess access, FileShare share) { string[] paths = Directory.GetFiles(path); foreach (string fpath in paths) { FileInfo finfo = new FileInfo(fpath); FileNode file = new FileNode(finfo.Name, (ulong)finfo.Length, new DelayedStream(cache.GenerateFileStream(finfo.FullName, FileMode.Open, access, share))); parent.AddChild(file); } paths = Directory.GetDirectories(path); foreach (string dpath in paths) { DirectoryInfo dinfo = new DirectoryInfo(dpath); DirectoryNode dir = new DirectoryNode(dinfo.Name); parent.AddChild(dir); FromPath(dir, dpath, cache, access, share); } }