improve:墨迹保存
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user