How to set the initialPath attribute to feed the SelectFolder method of the BrowseForFolder class?

376
2
Jump to solution
11-12-2018 04:37 AM
TomGeo
by
Occasional Contributor III

I need to provide my clients with the possibility to select a GDB from within a DockPaneView.

Now that I found out on how to get the parentWindow to satisfy the SelectFolder method I have to realize I cannot set the initialPath attribute. The method expects a string but writing "c:\\" still opens the dialog in the users home directory.

I found that I should be able to set the path to a sub-directory of the users home directory by writing e.g. "~/Documents".

Nothing off this works. I always start in the users home directory. But what I want is the possibility for the user to store the selected path in my solution as a resource variable and next time the SelectFolder dialog is opened the resource variable should retrieve the initial path from the resource file.

Has somebody a working example on how to set the initialPath attribute?

As said, the functionality is required to work from within a DockPaneView (WPF).

Best Thomas

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi Thomas,

Have you tried like this:

OpenItemDialog searchGdbDialog = new OpenItemDialog

{

Title = "Find GDB",

InitialLocation = Directory.GetCurrentDirectory(),

MultiSelect = false,

Filter = ItemFilters.featureDatasets_all

};

var ok = searchGdbDialog.ShowDialog();

For me it works, I always get last visited folder.

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi Thomas,

Have you tried like this:

OpenItemDialog searchGdbDialog = new OpenItemDialog

{

Title = "Find GDB",

InitialLocation = Directory.GetCurrentDirectory(),

MultiSelect = false,

Filter = ItemFilters.featureDatasets_all

};

var ok = searchGdbDialog.ShowDialog();

For me it works, I always get last visited folder.

TomGeo
by
Occasional Contributor III

Hi Gintautas,

I really like your solution to the problem. Using OpenItemDialog works in setting the directory and I am pretty sure I can also use it in combination with the resources. A bit of a disadvantage compared to the systems dialog is the indexing of the catalog when the dialog is opened.

Thanks for pointing me this way.

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos