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)
{
var directory = new DirectoryInfo(path);
if (directory.Exists)
if (!string.IsNullOrWhiteSpace(path))
{
return new BclStorageFolder(directory);
}
var file = new FileInfo(path);
if (file.Exists)
{
return new BclStorageFile(file);
var directory = new DirectoryInfo(path);
if (directory.Exists)
{
return new BclStorageFolder(directory);
}
var file = new FileInfo(path);
if (file.Exists)
{
return new BclStorageFile(file);
}
}
return null;

Loading…
Cancel
Save