improve:墨迹保存
This commit is contained in:
@@ -102,21 +102,13 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) when
|
||||
(ex is IOException ||
|
||||
ex is UnauthorizedAccessException) // 明确捕获与目录创建相关的异常
|
||||
ex is UnauthorizedAccessException)
|
||||
{
|
||||
// 如果创建失败则尝试使用文档目录
|
||||
basePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
// 如果创建失败则使用软件根目录作为最终备选
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder);
|
||||
|
||||
try {
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
catch (Exception) {
|
||||
// 如果文档目录也不可用,则使用软件根目录
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder);
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
|
||||
return Path.Combine(fullPath, $"{fileName}.png");
|
||||
|
||||
Reference in New Issue
Block a user