@@ -316,46 +316,42 @@ public void SavePluginSettings()
316
316
317
317
public void OpenDirectory ( string DirectoryPath , string FileNameOrFilePath = null )
318
318
{
319
- string targetPath ;
320
-
321
- if ( FileNameOrFilePath is null )
322
- {
323
- targetPath = DirectoryPath ;
324
- }
325
- else
326
- {
327
- targetPath = Path . IsPathRooted ( FileNameOrFilePath )
319
+ var explorerInfo = _settings . CustomExplorer ;
320
+ var explorerPath = explorerInfo . Path . Trim ( ) . ToLowerInvariant ( ) ;
321
+ var targetPath = FileNameOrFilePath is null
322
+ ? DirectoryPath
323
+ : Path . IsPathRooted ( FileNameOrFilePath )
328
324
? FileNameOrFilePath
329
325
: Path . Combine ( DirectoryPath , FileNameOrFilePath ) ;
330
- }
331
326
332
- var explorerInfo = _settings . CustomExplorer ;
333
- var explorerPath = explorerInfo . Path . Trim ( ) . ToLowerInvariant ( ) ;
334
-
335
- // If explorer.exe, ignore and pass only the path to Shell
327
+ using var explorer = new Process ( ) ;
336
328
if ( Path . GetFileNameWithoutExtension ( explorerPath ) == "explorer" )
337
329
{
338
- Process . Start ( new ProcessStartInfo
330
+ // Windows File Manager
331
+ // We should ignore and pass only the path to Shell to prevent zombie explorer.exe processes
332
+ explorer . StartInfo = new ProcessStartInfo
339
333
{
340
334
FileName = targetPath , // Not explorer, Only path.
341
335
UseShellExecute = true // Must be true to open folder
342
- } ) ;
343
- return ;
336
+ } ;
344
337
}
345
-
346
- // Custom File Manager
347
- var psi = new ProcessStartInfo
338
+ else
348
339
{
349
- FileName = explorerInfo . Path . Replace ( "%d" , DirectoryPath ) ,
350
- UseShellExecute = true ,
351
- Arguments = FileNameOrFilePath is null
352
- ? explorerInfo . DirectoryArgument . Replace ( "%d" , DirectoryPath )
353
- : explorerInfo . FileArgument
354
- . Replace ( "%d" , DirectoryPath )
355
- . Replace ( "%f" , targetPath )
356
- } ;
357
-
358
- Process . Start ( psi ) ;
340
+ // Custom File Manager
341
+ explorer . StartInfo = new ProcessStartInfo
342
+ {
343
+ FileName = explorerInfo . Path . Replace ( "%d" , DirectoryPath ) ,
344
+ UseShellExecute = true ,
345
+ Arguments = FileNameOrFilePath is null
346
+ ? explorerInfo . DirectoryArgument . Replace ( "%d" , DirectoryPath )
347
+ : explorerInfo . FileArgument
348
+ . Replace ( "%d" , DirectoryPath )
349
+ . Replace ( "%f" , targetPath )
350
+ } ;
351
+ }
352
+
353
+ // Start the process
354
+ explorer . Start ( ) ;
359
355
}
360
356
361
357
private void OpenUri ( Uri uri , bool ? inPrivate = null )
0 commit comments