11
11
using System . Threading ;
12
12
using System . Threading . Tasks ;
13
13
using System . Windows ;
14
- using System . Windows . Input ;
15
14
using System . Windows . Media ;
16
15
using CommunityToolkit . Mvvm . DependencyInjection ;
17
16
using Flow . Launcher . Core ;
@@ -319,45 +318,55 @@ public void SavePluginSettings()
319
318
320
319
( ( PluginJsonStorage < T > ) _pluginJsonStorages [ type ] ) . Save ( ) ;
321
320
}
322
-
323
- public void OpenDirectory ( string DirectoryPath , string FileNameOrFilePath = null )
321
+
322
+ public void OpenDirectory ( string directoryPath , string fileNameOrFilePath = null )
324
323
{
325
324
try
326
325
{
327
- using var explorer = new Process ( ) ;
328
326
var explorerInfo = _settings . CustomExplorer ;
329
327
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 ) ;
335
333
336
334
if ( Path . GetFileNameWithoutExtension ( explorerPath ) == "explorer" )
337
335
{
338
336
// Windows File Manager
339
- explorer . StartInfo = new ProcessStartInfo
337
+ if ( fileNameOrFilePath is null )
340
338
{
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
+ }
344
353
}
345
354
else
346
355
{
347
356
// Custom File Manager
357
+ using var explorer = new Process ( ) ;
348
358
explorer . StartInfo = new ProcessStartInfo
349
359
{
350
- FileName = explorerInfo . Path . Replace ( "%d" , DirectoryPath ) ,
360
+ FileName = explorerInfo . Path . Replace ( "%d" , directoryPath ) ,
351
361
UseShellExecute = true ,
352
- Arguments = FileNameOrFilePath is null
353
- ? explorerInfo . DirectoryArgument . Replace ( "%d" , DirectoryPath )
362
+ Arguments = fileNameOrFilePath is null
363
+ ? explorerInfo . DirectoryArgument . Replace ( "%d" , directoryPath )
354
364
: explorerInfo . FileArgument
355
- . Replace ( "%d" , DirectoryPath )
365
+ . Replace ( "%d" , directoryPath )
356
366
. Replace ( "%f" , targetPath )
357
367
} ;
368
+ explorer . Start ( ) ;
358
369
}
359
-
360
- explorer . Start ( ) ;
361
370
}
362
371
catch ( Win32Exception ex ) when ( ex . NativeErrorCode == 2 )
363
372
{
@@ -381,6 +390,7 @@ public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null
381
390
}
382
391
}
383
392
393
+
384
394
private void OpenUri ( Uri uri , bool ? inPrivate = null )
385
395
{
386
396
if ( uri . Scheme == Uri . UriSchemeHttp || uri . Scheme == Uri . UriSchemeHttps )
0 commit comments