keremcelik

Cannot Open Shapefile

Discussion created by keremcelik on Feb 22, 2011
Latest reply on Jul 7, 2011 by agray1
Hi,

I have a problem with opening shape file. I have a shape file in "C:\Shared\sample\sample.shp" (Of course the other files with extension dbf, prj, sbn, sbx, shp.xml and shx are in the same directory.) When I run the code below, I receive the exception called COMException was unhandled "Exception from HRESULT: 0x80040228".

I am running this code in Windows 7 Professional 64bit, ArcGIS 10 Engine and Visual Studio project target platform is x86.

If you have any idea, about the problem, please help me.

Thanks in advance.

Kerem Celik.

Type factory_type = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");

IWorkspaceFactory workspace_factory = (IWorkspaceFactory)Activator.CreateInstance(factory_type);

IFeatureWorkspace workspace = (IFeatureWorkspace)workspace_factory.OpenFromFile(@"C:\Shared\sample\", 0);

IFeatureClass feature_class = workspace.OpenFeatureClass(System.IO.Path.GetFileName(sample);

ESRI.ArcGIS.Carto.IFeatureLayer feature_layer = new FeatureLayerClass();

feature_layer.FeatureClass = (IFeatureClass)feature_class;

default_map.AddLayer((ILayer)feature_layer);

Outcomes