-1

I am using custom WPF FolderBrowserDialog in my application for Exporting data to particular folder location. It has read only properties SelectedPath, RootPath ,other properties and dependency properties available in it.

Now I want to assign my own path in RootFolder and SelectedPath. Since it is readonly properties I cannot able to assign any path in that. Also it has dependency property for the same properties as FolderBrowserDialog.RootFolderProperty.SetVale(dependencyproperty,object); Is it possible to assign values in the dependency proeprty using C# not by xaml?

How can I set default path to open with particular selected folder always(D:\Export) FolderBrowserDialog and also I want to implement the logic to remember the last selected folder. Please help me on this.

Suryakavitha
  • 1,371
  • 5
  • 33
  • 49

1 Answers1

3

I too have a WPF application and using the

System.Windows.Forms.FolderBrowserDialog

class. It does have the SelectedPath and RootFolder which are editable.

If you have a full path and set SelectedPath to it, that is where the dialog will default from a highlighted perspective. The dialog will start at the top of the screen instead of at the specific indented level. But if you scroll down, you would see the given path highlighted. As you go into each level, you would see each subsequent level pre-highlighted until the last level.

If from your variable of the FolderBrowserDialog, do (F12) or Right-Click "Go to Definition", it will take you to that declaration. You should see both properties as

public {get; set;}

Now with respect to the RootFolder, you can change that too, but that is based on an ENUM property of valid values from Environment.SpecialFolder which you would see in the declaration. Now, (F12) or Right-Click "Go to Definition" on the RootFolder and it will take you to the enum list of Environment special folders.

Now, if you wanted to hijack one of those uncommonly used folders and assigned to some other location, that would be a new step for you to take on.

DRapp
  • 47,638
  • 12
  • 72
  • 142