Why Folderbrowserdialog Dialog Does Not Scroll to Selected Folder

FolderBrowserDialog showing SelectedPath issue

I ended up using the Ookii dialogs folder browser dialog. Honestly it's just much better than the default folder browser. It also comes with an example, showing you how to use it.

How do I open a FolderBrowserDialog at the selected folder?

I was trying to assign a non-existent folder path to the SelectedFolder property. When you use a valid path, the root folder loses relevance. When you don't assign a SelectedFolder value, at least one of the Environment.SepcialFolder values will suffice.

COMING SOON: Attempts at using reflection to dynamically set a non-special root folder. Stay tuned.

How to remember the last selected folder in FolderBrowserDialog?

You could store the value of the SelectedPath property in a variable as soon as the ShowDialog() method returns:

private string _selectedPath = @"D:\Export\"; // <-- the default value
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog()
{
SelectedPath = _selectedPath
};
dialog.ShowDialog();
_selectedPath = dialog.SelectedPath;
}

FolderBrowserDialog C# SelectedPath always displayed at bottom

I was able to reproduce what you are see in Windows 7. This happens only the first time around though. So if you compress the expanded folder and try again clicking on it, it doesn't move the selected folder down but stays where it is and expands the subfolders under it. This doesn't happen if we use the arrow cursor to expand the folder. Sometimes I see that the selected folder even moves up so as to show all the contents. It might be by design or a minor bug.

FolderBrowserDialog last Folder Name

If what you want is to extract the last dir name from C:\Folder\Subfolder\Selected Folder then you can:

  • use Path.GetFileName method to acquire the last part from the path
  • call String.Split with the Path.PathSeparator and take the last array element

Updated in respect to @LucasTrzesniewski comment



Related Topics



Leave a reply



Submit