I am writing an add in that requires the input of several shapefiles and rasters. Unfortunately, the 'normal' open file dialog does not appropriately 'see' these file types. I need to be able to get file paths of these files without knowing the path before hand. Looking at the api reference this set of classes appear to be what i need. However, i am extremely new to programing in c# and am unsure how to achieve this. I have gotten as far as when button is clicked do a process##.
Hi Matthew,
You can use the BrowseProjectFilters and OpenItemDialog class to achieve what you need.
Pro offers a collection of existing BrowseProjectFilters that you can use. For example, "esri_browseDialogFilters_shapefiles" will allow you to browse just for shape files. Note: You can also make your own filters for other file types.
Here is a rough workflow:
Here are some wiki pages that can help you:
Thanks
Uma
Thanks. The magic bullet for me was the need for the framework dispatcher property. This is what i was needing for future people in the same spot.
var dlg = new OpenItemDialog();
dlg.Title = "Select DEM Raster";
FrameworkApplication.Current.Dispatcher.Invoke(() => {
var result = dlg.ShowDialog();
if (!dlg.ShowDialog().Value)
return;
var SelFile = dlg.Items.First();
///Verify expected outcome
/// MessageBox.Show($@"Path: {SelFile.Path}");
FPath = SelFile.Path;
FileName = System.IO.Path.GetFileName(SelFile.Path);
txtDEM.Text = FileName;
});