0

I want code to open ArcCatalog window with list of .sde files.The below code always opens an ArcCatalog window with home location. I have to go to database connections from the window which finally gives me list of .sde files. I want code to show list of .sde files directly on click on Add-In button instead of going to multiple selection options in the window and finally listing the .sde files.

                IGxDialog gxd = new GxDialogClass();
                gxd.AllowMultiSelect = false;
                gxd.ButtonCaption = "Add";                
                gxd.RememberLocation = false;

                IGxObjectFilter gxObjectFilter = new GxFilterDefaultDatabaseWorkspaces();
                gxd.ObjectFilter = gxObjectFilter;

                IEnumGxObject gxEnumObj;
                gxd.DoModalOpen(ArcMap.Application.hWnd, out gxEnumObj);
  • Why do you need to use the GxDialog? Why not just use System.Windows.Forms.Openfiledialog, then use IWorkspaceFactory2.OpenFromFile ? Also see gis.stackexchange.com/a/18156/59 – Kirk Kuykendall Jun 15 '18 at 0:35
  • If it helps the sde files are in %USERPROFILE%\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog (for ArcGIS desktop 10.2).. a connection file can be anywhere in the filesystem and works just fine but this is the location where ArcCatalog (and Map) save your database connections. To find them for other ArcGIS versions (in case they have moved) I use dir %USERPROFILE%*.SDE /S /B > %TEMP%\SDEConn.txt and then open the text file for the full paths to all your connection files, that could be modified to run as a shell command. – Michael Stimson Jun 15 '18 at 5:24
1

I found the answer. It turns out that there is a class with the name "GxFilterWorkspacesClass()". So if we use this class in the above code like mentoined below its gets the job done.

IGxObjectFilter gxObjectFilter = new GxFilterWorkspacesClass();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.