From 0e8671a7af66b7686fae7a2396497fdc07cbc419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E7=8C=AB=E8=B7=83?= <1043137532@qq.com> Date: Thu, 7 May 2026 18:28:17 +0800 Subject: [PATCH] =?UTF-8?q?ref:=20=E4=B8=80=E4=BA=9B=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shared/Utils/DirectoryUtils.cs | 4 ++-- Shared/Utils/PathUtils.cs | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Shared/Utils/DirectoryUtils.cs b/Shared/Utils/DirectoryUtils.cs index b4f6412..7cc048f 100644 --- a/Shared/Utils/DirectoryUtils.cs +++ b/Shared/Utils/DirectoryUtils.cs @@ -64,8 +64,8 @@ public static class DirectoryUtils { progressHandler?.Invoke(1); return; } - sourceDirName = PathUtils.WithoutLongPath(PathUtils.WithSeparator(sourceDirName, Path.DirectorySeparatorChar)); - destDirName = PathUtils.WithoutLongPath(PathUtils.WithSeparator(destDirName, Path.DirectorySeparatorChar)); + sourceDirName = PathUtils.WithoutLongPath(PathUtils.WithSeparator(sourceDirName)).Replace("/", @"\"); + destDirName = PathUtils.WithoutLongPath(PathUtils.WithSeparator(destDirName)).Replace("/", @"\"); int doneCount = 0; Lazy totalCount = new(() => DirectoryUtils.GetFiles(sourceDirName).Count()); Logger.Trace($"复制文件夹:{sourceDirName} → {destDirName}"); diff --git a/Shared/Utils/PathUtils.cs b/Shared/Utils/PathUtils.cs index 7b9636f..56bdde6 100644 --- a/Shared/Utils/PathUtils.cs +++ b/Shared/Utils/PathUtils.cs @@ -9,14 +9,6 @@ public static class PathUtils { public static string WithSeparator(string folder) => folder + (folder.EndsWithF(Path.DirectorySeparatorChar) || folder.EndsWithF(Path.AltDirectorySeparatorChar) ? "" : Path.DirectorySeparatorChar); - /// - /// 确保路径使用指定的文件夹分隔符,且末尾包含指定的文件夹分隔符。 - /// - public static string WithSeparator(string folder, char separator) { - folder = folder.Replace(Path.DirectorySeparatorChar, separator).Replace(Path.AltDirectorySeparatorChar, separator); - return folder + (folder.EndsWithF(separator) ? "" : separator); - } - /// /// 确保路径的结尾不包含文件夹分隔符。 /// @@ -33,7 +25,7 @@ public static class PathUtils { /// public static string ToShortPath(string fullName, bool keepFileName = false) { if (string.IsNullOrEmpty(fullName)) return fullName; - fullName = PathUtils.WithoutLongPath( fullName.Replace('/', '\\')); + fullName = PathUtils.WithoutLongPath(fullName.Replace('/', '\\')); if (fullName.Length <= 200) return fullName; // 保留文件名