File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Avalonia.CpuLimiter/Services Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 44using System ;
55using System . Collections . Generic ;
66using System . Linq ;
7+ using System . Runtime . InteropServices ;
78using System . Text ;
89using System . Threading . Tasks ;
910
@@ -22,14 +23,19 @@ public FilesService(Window target)
2223
2324 public async Task < IStorageFile ? > OpenFileAsync ( )
2425 {
25- var files = await _target . StorageProvider . OpenFilePickerAsync ( new FilePickerOpenOptions ( )
26+ FilePickerOpenOptions options = new ( )
2627 {
2728 Title = "Select executable file" ,
28- AllowMultiple = false
29+ AllowMultiple = false ,
30+ } ;
2931
32+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
33+ {
34+ options . FileTypeFilter = new FilePickerFileType [ ] { WinexeFileType } ;
35+ }
3036
31- } ) ;
3237
38+ var files = await _target . StorageProvider . OpenFilePickerAsync ( options ) ;
3339 return files . Count >= 1 ? files [ 0 ] : null ;
3440 }
3541
@@ -40,5 +46,10 @@ public FilesService(Window target)
4046 Title = "Save Text File"
4147 } ) ;
4248 }
49+
50+ public static FilePickerFileType WinexeFileType { get ; } = new ( "Windows exe" )
51+ {
52+ Patterns = new [ ] { "*.exe" } ,
53+ } ;
4354 }
4455}
You can’t perform that action at this time.
0 commit comments