1111using System . Threading ;
1212using System . Threading . Tasks ;
1313using System . Windows ;
14- using System . Windows . Input ;
1514using System . Windows . Media ;
1615using CommunityToolkit . Mvvm . DependencyInjection ;
1716using Flow . Launcher . Core ;
@@ -319,45 +318,55 @@ public void SavePluginSettings()
319318
320319 ( ( PluginJsonStorage < T > ) _pluginJsonStorages [ type ] ) . Save ( ) ;
321320 }
322-
323- public void OpenDirectory ( string DirectoryPath , string FileNameOrFilePath = null )
321+
322+ public void OpenDirectory ( string directoryPath , string fileNameOrFilePath = null )
324323 {
325324 try
326325 {
327- using var explorer = new Process ( ) ;
328326 var explorerInfo = _settings . CustomExplorer ;
329327 var explorerPath = explorerInfo . Path . Trim ( ) . ToLowerInvariant ( ) ;
330- var targetPath = FileNameOrFilePath is null
331- ? DirectoryPath
332- : Path . IsPathRooted ( FileNameOrFilePath )
333- ? FileNameOrFilePath
334- : Path . Combine ( DirectoryPath , FileNameOrFilePath ) ;
328+ var targetPath = fileNameOrFilePath is null
329+ ? directoryPath
330+ : Path . IsPathRooted ( fileNameOrFilePath )
331+ ? fileNameOrFilePath
332+ : Path . Combine ( directoryPath , fileNameOrFilePath ) ;
335333
336334 if ( Path . GetFileNameWithoutExtension ( explorerPath ) == "explorer" )
337335 {
338336 // Windows File Manager
339- explorer . StartInfo = new ProcessStartInfo
337+ if ( fileNameOrFilePath is null )
340338 {
341- FileName = targetPath ,
342- UseShellExecute = true
343- } ;
339+ // Only Open the directory
340+ using var explorer = new Process ( ) ;
341+ explorer . StartInfo = new ProcessStartInfo
342+ {
343+ FileName = directoryPath ,
344+ UseShellExecute = true
345+ } ;
346+ explorer . Start ( ) ;
347+ }
348+ else
349+ {
350+ // Open the directory and select the file
351+ Win32Helper . OpenFolderAndSelectFile ( targetPath ) ;
352+ }
344353 }
345354 else
346355 {
347356 // Custom File Manager
357+ using var explorer = new Process ( ) ;
348358 explorer . StartInfo = new ProcessStartInfo
349359 {
350- FileName = explorerInfo . Path . Replace ( "%d" , DirectoryPath ) ,
360+ FileName = explorerInfo . Path . Replace ( "%d" , directoryPath ) ,
351361 UseShellExecute = true ,
352- Arguments = FileNameOrFilePath is null
353- ? explorerInfo . DirectoryArgument . Replace ( "%d" , DirectoryPath )
362+ Arguments = fileNameOrFilePath is null
363+ ? explorerInfo . DirectoryArgument . Replace ( "%d" , directoryPath )
354364 : explorerInfo . FileArgument
355- . Replace ( "%d" , DirectoryPath )
365+ . Replace ( "%d" , directoryPath )
356366 . Replace ( "%f" , targetPath )
357367 } ;
368+ explorer . Start ( ) ;
358369 }
359-
360- explorer . Start ( ) ;
361370 }
362371 catch ( Win32Exception ex ) when ( ex . NativeErrorCode == 2 )
363372 {
@@ -381,6 +390,7 @@ public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null
381390 }
382391 }
383392
393+
384394 private void OpenUri ( Uri uri , bool ? inPrivate = null )
385395 {
386396 if ( uri . Scheme == Uri . UriSchemeHttp || uri . Scheme == Uri . UriSchemeHttps )
0 commit comments