-
When I call If it matters, I'm running this on macOS. Reproduction Make 2 folders on your Desktop:
And then run the following code: private async void Button_OnClick_WithoutSpaces(object? sender, RoutedEventArgs e)
{
await TryToOpenFolderOnDesktopWithName("TargetFolder");
}
private async void Button_OnClick_WithSpaces(object? sender, RoutedEventArgs e)
{
await TryToOpenFolderOnDesktopWithName("Target Folder");
}
private async Task TryToOpenFolderOnDesktopWithName(string folderName)
{
var basePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var targetPathWithSpaces = Path.Combine(basePath, folderName);
Console.WriteLine($"Trying '{targetPathWithSpaces}'");
var result = await DoOpenFilePickerAsync(targetPathWithSpaces);
}
private async Task<List<IStorageFile>?> DoOpenFilePickerAsync(String? providedPath)
{
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow?.StorageProvider is not { } provider)
throw new NullReferenceException("Missing StorageProvider instance.");
// Setup the starting folder
IStorageFolder? startingLocation = null;
if (providedPath != null)
{
startingLocation = await provider.TryGetFolderFromPathAsync(providedPath);
}
if (startingLocation != null)
{
Console.WriteLine($"-- Good starting location found - {startingLocation?.Path.AbsolutePath}");
}
else
{
Console.WriteLine($"-- startingLocation is null");
}
// TODO: BUG? if the path for startingFolder contains spaces, it will default to wherever it last opened.
var files = await provider.OpenFilePickerAsync(new FilePickerOpenOptions()
{
SuggestedStartLocation = startingLocation,
});
return files.ToList();//?.Count >= 1 ? files[0] : null;
} The Console output (for me) is:
When the I can click the WithoutSpaces button and navigate somewhere else. When I click the WithSpaces button, I go to the last location the other button was viewing. I've got to be doing something wrong... Anybody? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It was fixed in latest builds #17594 |
Beta Was this translation helpful? Give feedback.
It was fixed in latest builds #17594