The sample code is as follows:
Public StaticIworkspacename Browseworkspace (inthwnd outiworkspace ws) {igxobjectfiltercollection ipfilters=NewGxdialogclass (); //igxobjectfilter ipFilter1 = new Gxfilterfeaturedatasetsclass (); //feature DataSet, when exporting, the Ifeatureclassconverter object cannot be written to the dataset, where it is hidden//Ipfilters.addfilter (ipfilter1,false);Igxobjectfilter IFILT2 =NewGxfilterworkspacesclass ();//Database workspace, this class is ambiguous, do not know what the specific pointIpfilters.addfilter (IFILT2,false); Igxobjectfilter IpFilter3=NewGxfilterfilefolderclass ();//File WorkspaceIpfilters.addfilter (IpFilter3,false); Igxdialog Pgdialog=(Igxdialog) ipfilters; Pgdialog.rememberlocation=true; Pgdialog.title="Please select a working space"; Pgdialog.allowmultiselect=false; Ienumgxobject Presultenum=NULL; //iworkspace ws = NULL;WS =NULL; Iworkspacename WSN=NULL; if(Pgdialog.domodalopen (hwnd, outPresultenum) && Presultenum! =NULL) {Igxobject gxobj=Presultenum.next (); if(Gxobj isigxdatabase) {igxdatabase Gxdb= Gxobj asigxdatabase; if(Gxdb! =NULL) {ws=Gxdb.workspace; WSN=Gxdb.workspacename; } } Else if(Gxobj isIgxfolder) { //Todo:figure out what to decide which workspace to get for//a particular folder (Shapefiles, raster etc.) //Ienumname enumname = ((Igxfolder) gxobj). Filesystemworkspacenames; //For now just assume we want a shapefile ...Iworkspacefactory WSF =NewESRI. ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass (); WS=wsf. Openfromfile (((igxfile) gxobj). Path, HWND); Idataset Poutdataset= ws asIdataset; WSN= Poutdataset.fullname asIworkspacename; } Else if(Gxobj isIgxdataset) { //If the dataset workspaceIgxdataset Gxds = Gxobj asIgxdataset; if(Gxds! =NULL) {ws=GxDs.Dataset.Workspace; WSN=GxDs.DatasetName.WorkspaceName; }} marshal.finalreleasecomobject (Presultenum); } pGDialog.InternalCatalog.Close (); Marshal.finalreleasecomobject (Pgdialog); returnWSN; }
The code above can be expanded to call the ArcMap Add Layer window, etc.
ArcGIS AddIn Development: How to invoke a form that selects workspaces in ArcMap