Skip to content

Commit

Permalink
Merge pull request #885 from ywmoyue/dev
Browse files Browse the repository at this point in the history
4.7.6
  • Loading branch information
ywmoyue authored Oct 26, 2024
2 parents 57029c3 + d98113a commit 191cf72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/BiliLite.UWP/Extensions/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,19 @@ public static async Task<StorageFile> GetExportFile(string fileTypeChoiceKey, st
var file = await savePicker.PickSaveFileAsync();
return file;
}

public static async Task<bool> CheckFileExist(this string path)
{
try
{
var file = await StorageFile.GetFileFromPathAsync(path);
return file != null;
}
catch (Exception)
{
// 如果文件不存在或者路径无效,将捕获异常
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Pages/NewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private async void SetBackground()
}
else
{
if (!File.Exists(background))
if (!await background.CheckFileExist())
{
Notify.ShowMessageToast("背景图片不存在,请重新设置");
return;
Expand Down

0 comments on commit 191cf72

Please sign in to comment.