From cc38e8f14893c41e226fc55bccbb04a6cd00ae03 Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:16:15 +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 --- Ink Canvas/MainWindow_cs/MW_Screenshot.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_Screenshot.cs b/Ink Canvas/MainWindow_cs/MW_Screenshot.cs index 7c012387..28874069 100644 --- a/Ink Canvas/MainWindow_cs/MW_Screenshot.cs +++ b/Ink Canvas/MainWindow_cs/MW_Screenshot.cs @@ -104,10 +104,19 @@ namespace Ink_Canvas { (ex is IOException || ex is UnauthorizedAccessException) // 明确捕获与目录创建相关的异常 { - // 如果创建失败则使用文档目录 + // 如果创建失败则尝试使用文档目录 basePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder); - Directory.CreateDirectory(fullPath); + + try { + Directory.CreateDirectory(fullPath); + } + catch (Exception) { + // 如果文档目录也不可用,则使用软件根目录 + basePath = AppDomain.CurrentDomain.BaseDirectory; + fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder); + Directory.CreateDirectory(fullPath); + } } return Path.Combine(fullPath, $"{fileName}.png");