I have tried to use IGxDialog to open shapefiles by the codes below:
public static string getInputFile()
{
string filename;
IEnumGxObject enumGxObj;
IGxObject gxObj;
IGxObjectFilterCollection gxFilterColl;
IGxDialog gxDialog;
IGxObjectFilter gxObjFilter;
filename = "";
try
{
gxDialog = new GxDialog();
gxFilterColl = (IGxObjectFilterCollection)gxDialog;
gxDialog.AllowMultiSelect = false;
gxObjFilter = new GxFilterShapefiles();
//gxDialog.ObjectFilter = gxObjFilter;
gxFilterColl.AddFilter(gxObjFilter, true);
if (gxDialog.DoModalOpen(0, out enumGxObj))
{
gxObj = enumGxObj.Next();
filename = gxObj.FullName;
Logger.Debug("getInputFile filename = " + filename);
}
}
catch (Exception ex)
{
Logger.Debug("getInputFile error: " + ex.Message);
}
return filename;
}
But when the GxDialog is opened, the shapefiles are not found.
But the shapefiles are found in ArcCatalog
Are there any problems on the codes? Thanks.
Hi Mats,
On ArcGIS 10.3 your code works fine. What is your version of ArcGIS?
Thanks. My ArcMap and ArcObjects are both 10.7.
Do you need to limit this to only shapefiles or can any featureclass get selected? What happens when you use the GxFilterFeatureClasses filter?