From fe58c5c4d1320d399a795df8ec8e9cf8e6153b1b Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:02:27 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E5=A2=A8=E8=BF=B9=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainWindow_cs/MW_Save&OpenStrokes.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs index 364a5dd8..30c2a79d 100644 --- a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs +++ b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs @@ -54,18 +54,23 @@ namespace Ink_Canvas { } } catch (Exception fallbackEx) { - // 如果默认路径失败,切换到 C 盘根目录 - var cRootPath = @"C:\墨迹备份\" + Path.GetFileName(docPath); + // 如果文档路径保存失败,尝试用户目录 + string userDocPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "Documents", + "墨迹备份", + Path.GetFileName(docPath) + ); + try { - Directory.CreateDirectory(Path.GetDirectoryName(cRootPath)); - using (FileStream fs = new FileStream(cRootPath, FileMode.Create)) { + Directory.CreateDirectory(Path.GetDirectoryName(userDocPath)); + using (FileStream fs = new FileStream(userDocPath, FileMode.Create)) { inkCanvas.Strokes.Save(fs); - savePathWithName = cRootPath; // 使用 C 盘路径替代 - ShowNotification("墨迹保存至 C 盘: " + cRootPath); // 提示用户变更路径 + savePathWithName = userDocPath; } } - catch (Exception cRootEx) { - ShowNotification($"墨迹保存失败: {cRootEx.Message}"); + catch (Exception userFallbackEx) { + ShowNotification($"墨迹保存失败: {userFallbackEx.Message}"); return; } }