Skip to content

FileDialog.InitialDirectory does not work #3513

Closed

Description

@weltkante

.NET Core Version:
master

Have you experienced this same bug with .NET Framework?:
yes

Problem description:
FileDialog.InitialDirectory doesn't seem to work? It works for the classic dialog, but modern dialogs seem to ignore it, even though there is source code handling it. Debugging the source seems to throw FileNotFoundException when calling GetShellItemForPath. Might be an interop mistake?

Expected behavior:
FileDialog.InitialDirectory should actually set the directory.

Minimal repro:
Create and show an OpenFileDialog with a non-empty InitialDirectory (make sure you get the modern version of the dialog)

Activity

  1. weltkante commented on Jun 26, 2020

    @weltkante
    ContributorAuthor

    When fixing this, there is also desire to support special shell paths like "my computer". Might want to make sure that the fixed code understands these special paths when passing the string to shell API for translation, otherwise new API would be required to support them.

    Also see #3512 for adding InitialDirectory to FolderBrowserDialog, in case the API suggestion gets accepted before this is fixed, otherwise both can be done together.

  2. added
    🪲 bug
    enhancement
    and removed
    🪲 bug
    on Jul 2, 2020
  3. added this to the Future milestone on Jul 2, 2020
  4. added
    design-discussion
    help wanted
    on Jul 2, 2020
  5. kirsan31 commented on Oct 14, 2020

    @kirsan31
    Contributor

    From yesterday rc2 blog post:

    System.Windows.Forms.OpenFileDialog. Setting a value for the “InitialDirectory” property has no effect when running ShowDialog. Works fine with .NET Core 3.1.

  6. weltkante commented on Oct 14, 2020

    @weltkante
    ContributorAuthor

    Might want to reclassify as regression then, assuming 3.1 already used the new Vista dialog. (If 3.1 was still using the classic dialog, as mentioned above this still works.) My own test above already was against master so I didn't test 3.1 at all. Like mentioned above it fails during shell interop, might be interesting if 3.1 has this shell interop or is using different code.

  7. kirsan31 commented on Oct 14, 2020

    @kirsan31
    Contributor

    Yes, it's regression from 3.1. Dialogs are same, 3.1 works, 5.0 - not.

    Snipaste_2020-10-14_12-27-31

    Repro: OpenFileDialog.zip

    Good to be fixed before 5.0 release. @RussKie ?

  8. RussKie commented on Oct 14, 2020

    @RussKie
    Contributor

    Good to be fixed before 5.0 release.

    Sorry, .NET 5.0 is complete. This may meet a servicing bar for 5.0.x. /cc: @merriemcgaw

  9. self-assigned this
    on Oct 14, 2020
  10. added
    waiting-review
    on Oct 14, 2020
  11. kirsan31 commented on Oct 14, 2020

    @kirsan31
    Contributor

    Sorry, .NET 5.0 is complete. This may meet a servicing bar for 5.0.x.

    Complete for regression fixes on rc?
    I am not sure about modern/classic dialogs, but simple using of OpenFileDialog produces same dialog look on Win10 for netcoreapp3.1, net5.0-windows and net472. And InitialDirectory not working only in net5 :( So this is pure regression from .net framework and .net core3...

  12. merriemcgaw commented on Oct 14, 2020

    @merriemcgaw
    Contributor

    I'm going to have someone take another look at this ASAP. I can't promise we can get it into 5.0 GA simply because we're very close to locked down. Once we know what the root cause is and the risk of a fix we can determine if we can get it through in time for GA. If we can't, we can certainly look to it for servicing.

  13. 5 remaining items

  14. JeremyKuhne commented on Oct 14, 2020

    @JeremyKuhne
    Member

    Investigating

  15. ghost added
    🚧 work in progress
    on Oct 14, 2020
  16. removed
    help wanted
    on Oct 14, 2020
  17. ghost removed
    🚧 work in progress
    on Oct 14, 2020
  18. RussKie commented on Oct 15, 2020

    @RussKie
    Contributor

    Complete for regression fixes on rc?

    Tthere is a release process, and we're just one of the outer nodes on the graph. It takes weeks to prepare a public release, so we do have hard deadlines after which no change is accepted, and go into a subsequent servicing release.

  19. modified the milestones: Future, 5.0 GA on Oct 15, 2020
  20. ghost added
    🚧 work in progress
    on Oct 15, 2020
  21. ghost removed
    🚧 work in progress
    on Oct 15, 2020
  22. Amy-Li03 commented on Apr 1, 2021

    @Amy-Li03
    Contributor

    Verified issue on .Net 5.0.202 & .Net 6.0 latest build: 6.0.100-Preview.4.21181.20, this issue all fixed now. FileDialog.InitialDirectory works correctly.

  23. ghost locked as resolved and limited conversation to collaborators on Jan 31, 2022
  24. removed
    waiting-review
    on Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🪲 bug💥 regression-preview

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions