improve:墨迹保存

This commit is contained in:
CJK_mkp
2025-06-09 00:02:27 +08:00
parent a42aa75308
commit fe58c5c4d1
@@ -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;
}
}