diff --git a/Shared/Utils/PathUtils.cs b/Shared/Utils/PathUtils.cs index b8683ee..a0cf17a 100644 --- a/Shared/Utils/PathUtils.cs +++ b/Shared/Utils/PathUtils.cs @@ -225,6 +225,24 @@ public static class PathUtils { } } + /// + /// 比较两个路径是否相同。 + /// + public static bool IsSame(string path1, string path2) { + return PathUtils.Compare(PathUtils.ForCompare(path1), PathUtils.ForCompare(path2)) == 0; + } + /// + /// 比较两个路径,忽略大小写。 + /// + /// + /// 小于 0: 排在 之前。 + /// 等于 0:两个路径相等。 + /// 大于 0: 排在 之后。 + /// + public static int Compare(string path1, string path2) { + return string.Compare(PathUtils.ForCompare(path1), PathUtils.ForCompare(path2), true); + } + /// /// 将路径转换为兼容各种 Windows API 的格式。 /// 具体而言:将分隔符改为 \。添加前导的 \\?\。若为驱动器则添加末尾分隔符,否则去除分隔符。