Wednesday, 23 March 2016

arcobjects - Force a new AddDataDialog to open at a defined directory path


Is there a way to force the AddDataDialog to open to a specific path? I created a tool that when clicked on a specific feature will open the Add Data dialog, but I need it to open starting at a specified location. AddDataDialog doesn't have a property analogous to OpenFileDialog.InitialDirectory.



Answer



The GxDialog which the AddDataDialog uses is responsible for storing the last browse location which is opened on next dialog show. However, changing IGxDialog.StartingLocation has only effect if the dialog is actually shown, but you want to show the AddDataDialog instead.


There is one (rather dirty) way, and that's to change registry value named HKEY_CURRENT_USER\Software\ESRI\ArcCatalog\Settings\LastBrowseLocation to the catalog path you want the AddDataDialog navigate when shown. It is a string entry. For filesystem paths, it's quite straighforward provided that the disk drive is connected in ArcCatalog.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...