Skip to content

Vista part of the FolderBrowserDialog should be more compatible #3464

Closed

Description

@harborsiem
  • .NET Core Version:
    .NET Core SDK (gemäß "global.json"):
    Version: 3.1.301
    Commit: 7feb845744

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).

FolderBrowser_blank_Core

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:
FolderBrowser_blank

SelectedPath = "D:" should show this:
FolderBrowser_d

Minimal repro:

FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = string.Empty;
dialog.ShowDialog();

Activity

  1. weltkante commented on Jun 18, 2020

    @weltkante
    Contributor

    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}

  2. merriemcgaw commented on Jun 25, 2020

    @merriemcgaw
    Contributor

    This is by design, as @weltkante describes.

  3. weltkante commented on Jun 26, 2020

    @weltkante
    Contributor

    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?

  4. RussKie commented on Jun 26, 2020

    @RussKie
    Contributor
  5. weltkante commented on Jun 26, 2020

    @weltkante
    Contributor

    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.

  6. ghost locked as resolved and limited conversation to collaborators on Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    won't fix-by design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions