Skip to content

Commit c00d8db

Browse files
committed
Handle E_ABORT
1 parent 4a0f126 commit c00d8db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq;
99
using System.Net;
1010
using System.Runtime.CompilerServices;
11+
using System.Runtime.InteropServices;
1112
using System.Threading;
1213
using System.Threading.Tasks;
1314
using System.Windows;
@@ -379,6 +380,21 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null
379380
explorer.Start();
380381
}
381382
}
383+
catch (COMException ex) when (ex.ErrorCode == unchecked((int)0x80004004))
384+
{
385+
/*
386+
* The COMException with HResult 0x80004004 is E_ABORT (operation aborted).
387+
* Shell APIs often return this when the operation is canceled or the shell cannot complete it cleanly.
388+
* It most likely comes from Win32Helper.OpenFolderAndSelectFile(targetPath).
389+
* Typical triggers:
390+
* The target file/folder was deleted/moved between computing targetPath and the shell call.
391+
* The folder is on an offline network/removable drive.
392+
* Explorer is restarting/busy and aborts the request.
393+
* A selection request to a new/closing Explorer window is canceled.
394+
* Because it is commonly user- or environment-driven and not actionable,
395+
* we should treat it as expected noise and ignore it to avoid bothering users.
396+
*/
397+
}
382398
catch (Win32Exception ex) when (ex.NativeErrorCode == 2)
383399
{
384400
LogError(ClassName, "File Manager not found");

0 commit comments

Comments
 (0)