文件操作大小写兼容
This commit is contained in:
1 parent
d4af33f5be
commit
0ff787c5d9
3 files changed
+130
-48
No files matched your search
@@ -146,6 +146,17 @@ public static class PathUtils {
|
||||
return name.Contains(".") ? name.AfterLast(".").Lower() : "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取路径的盘符,返回一个大写字母。
|
||||
/// 若路径不包含盘符,则返回 <c>null</c>。
|
||||
/// </summary>
|
||||
public static char? GetDiskName(string? path) {
|
||||
if (string.IsNullOrEmpty(path)) return null;
|
||||
path = PathUtils.WithoutLongPath(path!);
|
||||
if (path.StartsWithF(@"\\") || path.StartsWithF("/")) return null;
|
||||
return char.ToUpper(path[0]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统一路径格式,以便比较。
|
||||
/// <para/>具体而言:将短路径展开,去除前导的 <c>\\?\</c>,将分隔符改为 \,去除末尾的分隔符。
|
||||
|
||||
Reference in new issue
Block a user