Skip to content

Commit

Permalink
chore: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli authored and emako committed Sep 18, 2024
1 parent 95feb87 commit 9e9bb10
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Wpf.Ui.Test/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,22 @@ public bool HasChildren(object parent)
{
if (parent is DirectoryInfo directory)
{
// 检查是否有子目录或文件
return directory.GetDirectories().Any() || directory.GetFiles().Any();
try
{
// 检查是否有子目录或文件
return directory.GetDirectories().Any() || directory.GetFiles().Any();
}
catch (UnauthorizedAccessException)
{
// 捕获没有权限的异常并返回 false
return false;
}
catch (Exception ex)
{
// 处理其他可能的异常
Console.WriteLine($"An error occurred: {ex.Message}");
return false;
}
}
return false;
}
Expand Down

0 comments on commit 9e9bb10

Please sign in to comment.