Browse Source

feat: TryGetFolderFromPathAsync return null instead of throw exception when empty folder path

pull/11694/head
Giuseppe Lippolis 3 years ago
parent
commit
db82e73697
  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