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
{{ message }}
Repository navigation
Vista part of the FolderBrowserDialog should be more compatible #3464
Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.301\
Host (useful for support):
Version: 3.1.5
Commit: 65cd789777
Have you experienced this same bug with .NET Framework?:
No
Problem description:
I set the SelectedPath property of the FolderBrowserDialog to string.Empty or to "D:". In this both cases the FolderBrowserDialog will show me any directory (possibly shows me the last directory I have used with OpenFileDialog).
When I set a directory to SelectedPath like "D:\Data" the FolderBrowserDialog will show this directory (this will be the correct behavior)
Expected behavior:
SelectedPath = string.Empty should show this:
SelectedPath = "D:" should show this:
Minimal repro:
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = string.Empty;
dialog.ShowDialog();
Note that D: sometimes means "current directory on drive D" - the correct path for "root of drive D" would be D:\. However I tested and D:\ does not work, there should be API added to select the initial folder, see last paragraph below
SelectedPath = string.Empty should show this:
I do not agree, if no selected path is specified it should be left to Windows to select the "common choice". "Dieser PC" is a choice many technical users may want, but non-technical users often want their "Documents" folder or similar. I think this is also the default for other applications, so WinForms should not require special coding to get the OS wide default.
Also Windows maintains a last visited folder per-application, this standard behavior should not get lost either. (Actually you can make it more fine-grained by supplying a usage GUID to maintain multiple last-visited folders per application, but WinForms only exposes this finer control on Open and Save dialogs via the ClientGuid).
Note there are APIs to set the default folder to one of the virtual shell folders like "Dieser PC" but this feature is not exposed through WinForms. Rather than changing how SelectedPath works it should be allowed to specify the starting directory including support for shell paths like ::{645FF040-5081-101B-9F08-00AA002F954E}
while this is by design there are several "missing features" of the native API which aren't exposed on the current FolderBrowserDialog
The ability to set a start folder is not exposed. You can indirectly set it by specifying the selected folder but that doesn't work for all cases as the OP describes. (This is a defect inherited by the old style browser dialog which only had a single tree view and didn't need to differentiate between start folder and selected folder, so the API didn't provide for it.)
The ClientGuid is only exposed for Open and Save dialogs, it should also be exposed for the new-style FolderBrowserDialog so that "current directories" can be preserved properly depending on application context. (Also inherited from old style browser dialog, it used a different API so didn't expose this feature.)
So while the desired behavior asked for by OP is not the right thing to do, his complaints are valid, they just have a different solution.
@merriemcgaw should I open a separate issue for designing and adding these missing APIs?
Created #3512 for API suggestion and #3513 for fixing FileDialog.InitialDirectory - doesn't seem to work even though there is code for handling it. Separate issues because a PR for fixing the existing calls may be doable faster than passing an API review.
Reacted by Merrie McGaw
ghost locked as resolved and limited conversation to collaborators on Jan 31, 2022
Activity
weltkante commentedon Jun 18, 2020
Note that
D:sometimes means "current directory on drive D" - the correct path for "root of drive D" would beD:\. However I tested andD:\does not work, there should be API added to select the initial folder, see last paragraph belowI do not agree, if no selected path is specified it should be left to Windows to select the "common choice". "Dieser PC" is a choice many technical users may want, but non-technical users often want their "Documents" folder or similar. I think this is also the default for other applications, so WinForms should not require special coding to get the OS wide default.
Also Windows maintains a last visited folder per-application, this standard behavior should not get lost either. (Actually you can make it more fine-grained by supplying a usage GUID to maintain multiple last-visited folders per application, but WinForms only exposes this finer control on Open and Save dialogs via the
ClientGuid).Note there are APIs to set the default folder to one of the virtual shell folders like "Dieser PC" but this feature is not exposed through WinForms. Rather than changing how
SelectedPathworks it should be allowed to specify the starting directory including support for shell paths like::{645FF040-5081-101B-9F08-00AA002F954E}merriemcgaw commentedon Jun 25, 2020
This is by design, as @weltkante describes.
weltkante commentedon Jun 26, 2020
while this is by design there are several "missing features" of the native API which aren't exposed on the current FolderBrowserDialog
ClientGuidis only exposed for Open and Save dialogs, it should also be exposed for the new-style FolderBrowserDialog so that "current directories" can be preserved properly depending on application context. (Also inherited from old style browser dialog, it used a different API so didn't expose this feature.)So while the desired behavior asked for by OP is not the right thing to do, his complaints are valid, they just have a different solution.
@merriemcgaw should I open a separate issue for designing and adding these missing APIs?
RussKie commentedon Jun 26, 2020
weltkante commentedon Jun 26, 2020
Created #3512 for API suggestion and #3513 for fixing
FileDialog.InitialDirectory- doesn't seem to work even though there is code for handling it. Separate issues because a PR for fixing the existing calls may be doable faster than passing an API review.