Skip to content

Commit bce3926

Browse files
authored
[#2190] - Checked for UnauthorizedAccessException on a selected directory (#2197)
1 parent 1666614 commit bce3926

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Files/Filesystem/StorageFileHelpers/StorageFileExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ public async static Task<StorageFolderWithPath> GetFolderWithPathFromPathAsync(s
124124
}
125125
else
126126
{
127-
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(value));
127+
try
128+
{
129+
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(value));
130+
}
131+
catch (UnauthorizedAccessException)
132+
{
133+
return await GetFolderWithPathFromPathAsync(Directory.GetParent(value).FullName, rootFolder, parentFolder).ConfigureAwait(false);
134+
}
128135
}
129136
}
130137

0 commit comments

Comments
 (0)