@@ -314,24 +314,48 @@ public void SavePluginSettings()
314314 ( ( PluginJsonStorage < T > ) _pluginJsonStorages [ type ] ) . Save ( ) ;
315315 }
316316
317- public void OpenDirectory ( string DirectoryPath , string FileNameOrFilePath = null )
317+ public void OpenDirectory ( string directoryPath , string fileNameOrFilePath = null )
318318 {
319- using var explorer = new Process ( ) ;
319+ string targetPath ;
320+
321+ if ( fileNameOrFilePath is null )
322+ {
323+ targetPath = directoryPath ;
324+ }
325+ else
326+ {
327+ targetPath = Path . IsPathRooted ( fileNameOrFilePath )
328+ ? fileNameOrFilePath
329+ : Path . Combine ( directoryPath , fileNameOrFilePath ) ;
330+ }
331+
320332 var explorerInfo = _settings . CustomExplorer ;
333+ var explorerPath = explorerInfo . Path . Trim ( ) . ToLowerInvariant ( ) ;
334+
335+ // If explorer.exe, ignore and pass only the path to Shell
336+ if ( Path . GetFileNameWithoutExtension ( explorerPath ) == "explorer" )
337+ {
338+ Process . Start ( new ProcessStartInfo
339+ {
340+ FileName = targetPath , // Not explorer, Only path.
341+ UseShellExecute = true // Must be true to open folder
342+ } ) ;
343+ return ;
344+ }
321345
322- explorer . StartInfo = new ProcessStartInfo
346+ // Custom File Manager
347+ var psi = new ProcessStartInfo
323348 {
324- FileName = explorerInfo . Path . Replace ( "%d" , DirectoryPath ) ,
349+ FileName = explorerInfo . Path . Replace ( "%d" , directoryPath ) ,
325350 UseShellExecute = true ,
326- Arguments = FileNameOrFilePath is null
327- ? explorerInfo . DirectoryArgument . Replace ( "%d" , DirectoryPath )
351+ Arguments = fileNameOrFilePath is null
352+ ? explorerInfo . DirectoryArgument . Replace ( "%d" , directoryPath )
328353 : explorerInfo . FileArgument
329- . Replace ( "%d" , DirectoryPath )
330- . Replace ( "%f" ,
331- Path . IsPathRooted ( FileNameOrFilePath ) ? FileNameOrFilePath : Path . Combine ( DirectoryPath , FileNameOrFilePath )
332- )
354+ . Replace ( "%d" , directoryPath )
355+ . Replace ( "%f" , targetPath )
333356 } ;
334- explorer . Start ( ) ;
357+
358+ Process . Start ( psi ) ;
335359 }
336360
337361 private void OpenUri ( Uri uri , bool ? inPrivate = null )
0 commit comments