ookii-dialogs / ookii-dialogs-wpf

Awesome dialogs for Windows Desktop applications built with Microsoft .NET (WPF)
BSD 3-Clause "New" or "Revised" License
1.14k stars 85 forks source link

VistaFolderBrowserDialog: Set InitialDirectory (not SelectedPath) #35

Open nzain opened 3 years ago

nzain commented 3 years ago

The VistaFolderBrowserDialog does not have an InitialDirectory property (like the open/save file variants do). The SelectedPath property sounds similar, but actually navigates to the parent directory and sets the given directory name as input for the textbox at the bottom.

Unless (hidden feature) you append a trailing backslash or slash. In that case, the dialog opens in the given path and nothing is selected. I guess this only works because Path.GetDirectoryName(..) is tricked into a different result here: https://github.com/augustoproiete/ookii-dialogs-wpf/blob/d157189c795d4fdb500662bde8ad328d7d3eb602/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs#L280-L290

Whatever the implementation details, it would be good to have an explicit API that allows to set the initial directory.

Additional remarks:

nzain commented 3 years ago

I've created a PR and tried to match your coding style. Feel free to change the style.

nzain commented 3 years ago

@augustoproiete did you have the time to look at my PR? The change is small and does not change / break existing code.

augustoproiete commented 3 years ago

Hey @nzain thanks for the nudge. I looked at the code and in principle looks great. I'll set aside some time this week to run a few tests and get this merged in.

nzain commented 3 years ago

Did you run into problems? I'm willing to help!

antikmozib commented 1 year ago

I believe this is same behaviour utilised by the WinForms FolderBrowserDialog. So I reckon this is default behaviour for these type of selectors, and hence, would leave it as it is to avoid confusions.