Changeset 2282 for trunk/eraser/Eraser.Util/Shell.cs
- Timestamp:
- 1/4/2011 2:42:32 AM (2 years ago)
- File:
-
- 1 edited
-
trunk/eraser/Eraser.Util/Shell.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/Shell.cs
r2112 r2282 142 142 143 143 /// <summary> 144 /// Verifies if the path given is rooted at the given absolute path. 145 /// </summary> 146 /// <param name="absolutePath">The root path.</param> 147 /// <param name="path">The path to verify.</param> 148 /// <returns>True if the path provided is a subfolder/sub-file of the provided root path.</returns> 149 public static bool IsRootedAt(FileSystemInfo absolutePath, string path) 150 { 151 //Convert the path in question to an absolute path 152 if (!Path.IsPathRooted(path)) 153 path = Path.GetFullPath(path); 154 155 //Split the directory path to its component folders 156 string[] absoluteDirectories = absolutePath.FullName.Split( 157 Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); 158 string[] relativeDirectories = path.Split( 159 Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); 160 161 //Compare element by element; if the absolute path compares till the end, the 162 //provided path is a subdirectory 163 for (int i = 0; i < absoluteDirectories.Length; ++i) 164 if (absoluteDirectories[i] != relativeDirectories[i]) 165 return false; 166 167 return true; 168 } 169 170 /// <summary> 144 171 /// A List of known folder IDs in the shell namespace. 145 172 /// </summary>
Note: See TracChangeset
for help on using the changeset viewer.
