PathUtils.IsParentOf

This commit is contained in:
龙腾猫跃 committed 2026-06-29 07:42:59 +08:00
1 parent 0a3b21505a
commit a1fcb5241a
6 files changed
+20 -18

No files matched your search

+9
View File
@@ -178,6 +178,15 @@ public static class PathUtils {
#endregion
/// <summary>
/// 判断 <param name="parentPath"/> 是否为 <paramref name="childPath"/> 的父路径,或两者是否相同。
/// </summary>
public static bool IsParentOf(string parentPath, string childPath) {
parentPath = PathUtils.ForCompare(parentPath);
childPath = PathUtils.ForCompare(childPath);
return childPath.StartsWithF(parentPath + @"\") || childPath == parentPath;
}
}
/// <summary>