Open DevilDog2098 opened 2 years ago
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
I would like to see this feature as well. For my case, I have found that if the last-chosen path was one on the network, it can take a while to load the file picker if the user is not connected to the VPN. I would leverage a cancellation token to check that the file picker UI is shown within a reasonable time to set the starting path so it is the user's home (e.g., %USERPROFILE%
on Windows or $HOME
on Linux and macOS) if there is a timeout.
I also would like to have this feature, so that the user doesn't need to take care about the directory anymore. Is there any workaround?
I have done some research, and it appears the problem with this feature request is that the platform-specific implementations of the file/folder picker are inconsistent about providing an option to specify the starting directory.
Operating System | C# SDK Namespace for file picker | File/Folder picker allows specifying start directory | Qualififications/Caveats | API Documentation |
---|---|---|---|---|
Windows | Windows.Storage.Pickers |
No | The SuggestedStartLocation property only allows you to set predefined locations. |
Windows.Storage.Pickers |
Android | Android.Content |
Sometimes | The ACTION_GET_CONTENT does not support opening in a specific location; however,Intent#ACTION_OPEN_DOCUMENT Intent#ACTION_CREATE_DOCUMENT Intent#ACTION_OPEN_DOCUMENT_TREE do support it through the EXTRA_INITIAL_URI intent extra. |
Android.Content |
iOS | UIKit.UIDocumentPickerViewController |
Yes | You can specify the starting directory by setting the directoryURL property. However, this property has no effect in Mac apps built with Mac Catalyst. |
UIDocumentPickerViewController |
Tizen | Tizen.Applications.FilePicker |
No | The API does not provide a way to specify a custom start path for the file picker. | Tizen.Applications.FilePicker |
MacCatalyst | UIKit.UIDocumentPickerViewController |
No | The directoryURL property has no effect in Mac apps built with Mac Catalyst. |
UIDocumentPickerViewController |
macOS | AppKit.NSOpenPanel |
No | The NSOpenPanel does not support opening in a specific location programmatically. |
NSOpenPanel |
tvOS | UIKit.UIDocumentPickerViewController |
Unknown | I couldn't find specific information on how to specify a starting directory for the file picker in tvOS. | UIDocumentPickerViewController |
watchOS | WatchKit.WKInterfacePicker |
No | In watchOS, you can use the Photos picker view to browse and select images and videos from the photo library. However, it doesn't seem like you can specify a starting directory. | WKInterfacePicker |
Since the standard APIs provided by the OS C# SDK are inconsistent on this point, implementing this feature in a cross-platform UI framework like .NET MAUI would require developing custom file-picker libraries. I think going down this road would make MAUI opinionated about UI implementations and be opposed to the generic, flexible design goals of .NET MAUI.
@mavaddat I haven't checked yet all of the linked documentations, but isn't this somewhat covered in Android by the "EXTRA_INITIAL_URI" Parameter when calling the "ACTION_OPEN_DOCUMENT" Intent?
Isn't this somewhat covered in Android by the "EXTRA_INITIAL_URI" Parameter when calling the "ACTION_OPEN_DOCUMENT" Intent?
Yes, it looks like you are correct. Although the ACTION_GET_CONTENT does not support opening in a specific location, it looks like Intent#ACTION_OPEN_DOCUMENT Intent#ACTION_CREATE_DOCUMENT Intent#ACTION_OPEN_DOCUMENT_TREE supports it through the EXTRA_INITIAL_URI intent extra. I have updated the table above.
I also need this feature. I just wrote my very first MAUI app (a short 300 lines of code) for a friend to assist him with a tedious, mundane task on his Mac. The very first thing he asked for when I sent him the application, was to be able to have it come up with a default folder when opening a file.
Description
I would love to have the ability to set a default directory in the FilePicker type. i.e. Set FilePicker to a specific directory when it displays to the user.
Public API Changes
public class PickOptions { public PickOptions();
}
Intended Use-Case
In my application I have the ability for users to Open and Backup/Restore project files. Currently when "Open Project" is selected the FilePicker opens in the Documents directory. Being able to set a default directory for the picker to open too would save a lot of support issues once a production release is pushed out.