PickFolders option for OpenFileDialog (minimal)#6374
Closed
miloush wants to merge 1 commit intodotnet:mainfrom
Closed
PickFolders option for OpenFileDialog (minimal)#6374miloush wants to merge 1 commit intodotnet:mainfrom
miloush wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
|
@miloush Reason why this is still being a draft? |
This was referenced Nov 1, 2022
Merged
Contributor
Author
|
Closing in favor of #7244 which passed API review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For discussion. Fixes #438. Further discussion in #4039. Previous attempt: #6351
Description
Allows developers to ask the user to select a folder, a feature known as
FolderBrowserDialogin WinForms.This PR is the minimal code changes needed to introduce the feature. It closely reflects the underlying API design, i.e. the ability to specify
FOS_PICKFOLDERSon theIOpenFileDialog. This is a backwards compatible solution - no public API has been moved or removed and no existing behavior has changed.A custom option
OPTION_PICKFOLDERSis introduced that setsFOS_PICKFOLDERSand clearsOFN_FILEMUSTEXISTwhen the dialog is prepared.New visible members
In
OpenFileDialog:public bool PickFolders { get; set; }Legacy behavior
Legacy code path (pre-Vista) ignores the flag and shows standard file open dialog.
Customer Impact
Without this fix, users have to either use WinForms'
FolderBrowserDialog, resort to 3rd party libraries or re-implement the wholeIFileDialogAPI. #438 is currently the top voted issue in the repository.Regression
No.
Testing
Compiled custom PresentationFramework.dll and tested in 6.0.2 x86 app that both folder browsing and file browsing works as expected.
Risk
Low - existing behavior not affected, minimal code changes. Setting
Filteron a dialog withPickFolderswill throwCOMExceptiononShowDialog().The bit used by
OPTION_PICKFOLDERSis currently unused in both legacy andIOpenFileDialogAPI, but it might get allocated in the future. This would however not break this feature as the bits are masked out (same happened in the past withOPTION_ADDEXTENSION).User code that processes "used" file dialogs could now be handed an instance that unexpectedly contains folders in the
FileName(s)properties. This, however, would have to be explicitly caused using new code. Unexpected file operations on folders (i.e. trying to open them) yield IO exceptions that the existing code should be already handling./cc @ThomasGoulet73 @batzen
Microsoft Reviewers: Open in CodeFlow