0

I want to read a shapefile by Arcobject and C#. I used the ArcGIS Snippet and write follow code:

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
IWorkspaceFactory wsf = new ShapefileWorkspaceFactory();
IWorkspace ws = wsf.OpenFromFile(@"E:\Data\shap file iran\IRN_adm\", 0);
IFeatureWorkspace fws = ws as IFeatureWorkspace;
IFeatureClass fc = fws.OpenFeatureClass("Province.shp");

but in line 3 returned error:

Exception from HRESULT: 0x80040228

Whats the matter?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Mahdi Ahmadi
  • 441
  • 4
  • 12
  • Did you tried `IWorkspace ws = wsf.OpenFromFile(@"E:\Data\shap file iran\IRN_adm\Province.shp", 0);` – Shweta Pathak Oct 15 '15 at 06:34
  • Yes, I found that problem relates to license and i fixed that. but next i have problem with "IFeatureWorkspace fws = ws as IFeatureWorkspace; IFeatureClass fc = fws.OpenFeatureClass(@"E:\Data\shap file iran\IRN_adm\Province");" – Mahdi Ahmadi Oct 15 '15 at 06:54
  • I think OpenFeatureClass() should only take the featureclass name (e.g. "Province"), and not the full path or the file extension. The path you have already defined in your workspace factory. – pvdev Oct 15 '15 at 14:29

0 Answers0