fix: 长路径处理有误
This commit is contained in:
1 parent
a1a367a749
commit
7402647008
1 file changed
+2
-2
@@ -49,10 +49,10 @@ public static class PathUtils {
|
|||||||
|
|
||||||
// 缩短路径
|
// 缩短路径
|
||||||
char[] buffer = new char[260];
|
char[] buffer = new char[260];
|
||||||
int result = GetShortPathNameW(pathToShorten, buffer, buffer.Length);
|
int result = GetShortPathNameW(PathUtils.WithLongPath(pathToShorten), buffer, buffer.Length);
|
||||||
if (result == 0) return fullName;
|
if (result == 0) return fullName;
|
||||||
string shortPath = new(buffer, 0, result);
|
string shortPath = new(buffer, 0, result);
|
||||||
return Path.Combine(shortPath, pathToKeep);
|
return PathUtils.WithoutLongPath(Path.Combine(shortPath, pathToKeep));
|
||||||
}
|
}
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern int GetShortPathNameW(string lpszLongPath, [Out] char[] buffer, int cchBuffer);
|
private static extern int GetShortPathNameW(string lpszLongPath, [Out] char[] buffer, int cchBuffer);
|
||||||
|
|||||||
Reference in new issue
Block a user