improve:墨迹保存
This commit is contained in:
@@ -54,18 +54,23 @@ namespace Ink_Canvas {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception fallbackEx) {
|
catch (Exception fallbackEx) {
|
||||||
// 如果默认路径失败,切换到 C 盘根目录
|
// 如果文档路径保存失败,尝试用户目录
|
||||||
var cRootPath = @"C:\墨迹备份\" + Path.GetFileName(docPath);
|
string userDocPath = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||||
|
"Documents",
|
||||||
|
"墨迹备份",
|
||||||
|
Path.GetFileName(docPath)
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(cRootPath));
|
Directory.CreateDirectory(Path.GetDirectoryName(userDocPath));
|
||||||
using (FileStream fs = new FileStream(cRootPath, FileMode.Create)) {
|
using (FileStream fs = new FileStream(userDocPath, FileMode.Create)) {
|
||||||
inkCanvas.Strokes.Save(fs);
|
inkCanvas.Strokes.Save(fs);
|
||||||
savePathWithName = cRootPath; // 使用 C 盘路径替代
|
savePathWithName = userDocPath;
|
||||||
ShowNotification("墨迹保存至 C 盘: " + cRootPath); // 提示用户变更路径
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception cRootEx) {
|
catch (Exception userFallbackEx) {
|
||||||
ShowNotification($"墨迹保存失败: {cRootEx.Message}");
|
ShowNotification($"墨迹保存失败: {userFallbackEx.Message}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user