From b0c6bbb8f7debe414b705f551206e2cfcaa85611 Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:09:24 +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 | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs index dcb88069..4b8b77d3 100644 --- a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs +++ b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs @@ -47,27 +47,22 @@ namespace Ink_Canvas { Path.GetFileNameWithoutExtension(savePathWithName) + "_retry.icstk"); // 使用正确的原始文件名 try { - Directory.CreateDirectory(Path.GetDirectoryName(docPath)); - using (FileStream fs = new FileStream(docPath, FileMode.Create)) { + // 修改保存路径为软件所在目录下的 Saves 文件夹 + string appDirectory = AppDomain.CurrentDomain.BaseDirectory; + string saveDirectory = Path.Combine(appDirectory, "Saves"); + Directory.CreateDirectory(saveDirectory); // 自动创建 Saves 目录 + + string fileName = Path.GetFileName(docPath); // 保留原始文件名 + string newPath = Path.Combine(saveDirectory, fileName); // 新路径组合 + + using (FileStream fs = new FileStream(newPath, FileMode.Create)) { inkCanvas.Strokes.Save(fs); - savePathWithName = docPath; // 更新通知使用的路径变量 + savePathWithName = newPath; // 更新通知使用的路径变量 } } catch (Exception fallbackEx) { - // 如果文档路径保存失败,尝试保存到软件根目录 - string rootPath = AppDomain.CurrentDomain.BaseDirectory; - string rootFilePath = Path.Combine(rootPath, Path.GetFileName(docPath)); - try { - Directory.CreateDirectory(Path.GetDirectoryName(rootFilePath)); - using (FileStream fs = new FileStream(rootFilePath, FileMode.Create)) { - inkCanvas.Strokes.Save(fs); - savePathWithName = rootFilePath; // 更新通知使用的路径变量 - } - } - catch (Exception rootEx) { - ShowNotification($"墨迹保存失败: {fallbackEx.Message} | 根目录保存失败: {rootEx.Message}"); - return; - } + ShowNotification($"墨迹保存失败: {fallbackEx.Message}"); + return; } } catch (Exception ex) {