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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
9 deletions
-
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; |
|
|
|
|