improve:墨迹保存
This commit is contained in:
@@ -54,8 +54,20 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception fallbackEx) {
|
||||
ShowNotification($"墨迹保存失败: {fallbackEx.Message}");
|
||||
return;
|
||||
// 如果默认路径失败,切换到 C 盘根目录
|
||||
var cRootPath = @"C:\墨迹备份\" + Path.GetFileName(docPath);
|
||||
try {
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(cRootPath));
|
||||
using (FileStream fs = new FileStream(cRootPath, FileMode.Create)) {
|
||||
inkCanvas.Strokes.Save(fs);
|
||||
savePathWithName = cRootPath; // 使用 C 盘路径替代
|
||||
ShowNotification("墨迹保存至 C 盘: " + cRootPath); // 提示用户变更路径
|
||||
}
|
||||
}
|
||||
catch (Exception cRootEx) {
|
||||
ShowNotification($"墨迹保存失败: {cRootEx.Message}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
@@ -102,8 +102,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) when
|
||||
(ex is IOException ||
|
||||
ex is UnauthorizedAccessException ||
|
||||
ex is DirectoryNotFoundException) // 明确捕获与目录创建相关的异常
|
||||
ex is UnauthorizedAccessException) // 明确捕获与目录创建相关的异常
|
||||
{
|
||||
// 如果创建失败则使用文档目录
|
||||
basePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
|
||||
Reference in New Issue
Block a user