Browse Source

Merge pull request #11694 from workgroupengineering/features/Issue_11681

feat: TryGetFolderFromPathAsync return null instead of throw exception
baget-ci-test
Max Katz 3 years ago
committed by GitHub
parent
commit
82b37dbc14
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs

21
src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs

@ -10,16 +10,19 @@ internal static class StorageProviderHelpers
{ {
public static IStorageItem? TryCreateBclStorageItem(string path) public static IStorageItem? TryCreateBclStorageItem(string path)
{ {
var directory = new DirectoryInfo(path); if (!string.IsNullOrWhiteSpace(path))
if (directory.Exists)
{ {
return new BclStorageFolder(directory); var directory = new DirectoryInfo(path);
} if (directory.Exists)
{
var file = new FileInfo(path); return new BclStorageFolder(directory);
if (file.Exists) }
{
return new BclStorageFile(file); var file = new FileInfo(path);
if (file.Exists)
{
return new BclStorageFile(file);
}
} }
return null; return null;

Loading…
Cancel
Save