You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing with OpenFilePickerAsync(). If the FileTypeFilter of FilePickerOpenOptions is set to null, SuggestedStartLocation behaves as expected every time.
However, if the FileTypeFilter is set to something non-null, the SuggestedStartLocation works only the first time OpenFilePickerAsync() is called. The second time it is called, the starting location will be wherever the picker was left after the first call.
Quitting the app and re-launching will cause the SuggestedStartLocation to be respected again, but only the first time OpenFilePickerAsync() is called.
If it matters, I'm running this on macOS and Avalonia 11.2.3. Any assistance would be greatly appreciated.
Reproduction
Make 2 folders on your Desktop:
one called "Target Folder"
the other named "Target Folder 2"
And then run the following code:
privateasyncvoidButton_OnClick_WithSpaces_COMPLEX(object?sender,RoutedEventArgse){awaitTryToOpenFolderOnDesktopWithName_COMPLEX("Target Folder");}privateasyncvoidButton_OnClick_WithSpaces2_COMPLEX(object?sender,RoutedEventArgse){awaitTryToOpenFolderOnDesktopWithName_COMPLEX("Target Folder 2");}privateasyncTaskTryToOpenFolderOnDesktopWithName_COMPLEX(stringfolderName){varbasePath=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);vartargetPathWithSpaces=Path.Combine(basePath,folderName);Console.WriteLine($"Trying '{targetPathWithSpaces}'");varresult=awaitDoOpenFilePickerAsync_COMPLEX(targetPathWithSpaces);}privateasyncTask<List<IStorageFile>?>DoOpenFilePickerAsync_COMPLEX(String?providedPath){if(Application.Current?.ApplicationLifetimeis not IClassicDesktopStyleApplicationLifetimedesktop||desktop.MainWindow?.StorageProvideris not {}provider)thrownewNullReferenceException("Missing StorageProvider instance.");// Setup the starting folderIStorageFolder?startingLocation=null;if(providedPath!=null){startingLocation=awaitprovider.TryGetFolderFromPathAsync(providedPath);}if(startingLocation!=null){Console.WriteLine($"-- Good starting location found - {startingLocation?.Path.AbsolutePath}");}else{Console.WriteLine($"-- startingLocation is null");}varfilePickerOptions=newFilePickerOpenOptions(){Title="Choose an XML file",AllowMultiple=true,FileTypeFilter=new[]{FilePickerFileTypes.TextPlain},//FileTypeFilter = null,SuggestedStartLocation=startingLocation,};varfiles=awaitprovider.OpenFilePickerAsync(filePickerOptions);returnfiles.ToList();}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm playing with
OpenFilePickerAsync()
. If theFileTypeFilter
ofFilePickerOpenOptions
is set to null,SuggestedStartLocation
behaves as expected every time.However, if the
FileTypeFilter
is set to something non-null, theSuggestedStartLocation
works only the first timeOpenFilePickerAsync()
is called. The second time it is called, the starting location will be wherever the picker was left after the first call.Quitting the app and re-launching will cause the
SuggestedStartLocation
to be respected again, but only the first timeOpenFilePickerAsync()
is called.If it matters, I'm running this on macOS and Avalonia 11.2.3. Any assistance would be greatly appreciated.
Reproduction
Make 2 folders on your Desktop:
And then run the following code:
Beta Was this translation helpful? Give feedback.
All reactions