using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using RainmeterStudio.Model; namespace RainmeterStudio.Utils { public static class DirectoryHelper { /// /// Gets a tree of the folder structure /// /// Folder /// A tree public static Tree GetFolderTree(string folder) { // Build tree object Reference reference = new Reference(Path.GetFileName(folder), folder); Tree tree = new Tree(reference); // Navigate folder structure if (Directory.Exists(folder)) { foreach (var item in Directory.EnumerateDirectories(folder) .Concat(Directory.EnumerateFiles(folder))) { tree.Add(GetFolderTree(item)); } } // Return tree return tree; } /// /// Returns true if two paths are equal /// /// First path /// Second path /// True if the paths are equal public static bool PathsEqual(string path1, string path2) { path1 = System.IO.Path.GetFullPath(path1); path2 = System.IO.Path.GetFullPath(path2); return String.Equals(path1, path2, StringComparison.InvariantCultureIgnoreCase); } } }