Skip to content

Commit 5348c03

Browse files
authored
Fix: Fixed issue that caused NullReferenceException to be raised unnecessarily (#11888)
1 parent c0f7063 commit 5348c03

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Files.App/Shell/Win32Shell.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ static Win32Shell()
3939
try
4040
{
4141
using var shellFolder = ShellFolderExtensions.GetShellItemFromPathOrPidl(path) as ShellFolder;
42-
folder = ShellFolderExtensions.GetShellFileItem(shellFolder);
4342

44-
if ((controlPanel.PIDL.IsParentOf(shellFolder.PIDL, false) ||
43+
if (shellFolder is null ||
44+
(controlPanel.PIDL.IsParentOf(shellFolder.PIDL, false) ||
4545
controlPanelCategoryView.PIDL.IsParentOf(shellFolder.PIDL, false)) &&
46-
(shellFolder is null || !shellFolder.Any()))
46+
!shellFolder.Any())
4747
{
4848
// Return null to force open unsupported items in explorer
4949
// only if inside control panel and folder appears empty
5050
return (null, flc);
5151
}
5252

53+
folder = ShellFolderExtensions.GetShellFileItem(shellFolder);
54+
5355
if (action == "Enumerate")
5456
{
5557
foreach (var folderItem in shellFolder.Skip(from).Take(count))

0 commit comments

Comments
 (0)