Shapefile location change repair. HResult E_FAIL

المشرف العام

Administrator
طاقم الإدارة
I'm working on a ArcMap plugin using ArcObjects that will change the location of a shapefile that is broken. However, I'm getting HResult Error E_Fail whenever I try opening the feataure class. This is the specific HResult value: -2147467259

Here's the setup. I have a MXD file with a shapefile that I created. This shapefile's location has been moved from the MXD file expects it to be. It expects it to be in C:\usr\Desktop, but I have moved it to C:\usr\Desktop\tmp. The shapefile is called "New_Shapefile.shp"

The goal is to repair the location of the shapefile. Here is the current code I have for shapefile replace. The following fails whenever I try opening the feature dataset.

IFeatureLayer featureLayer = (IFeatureLayer)pLayer //pLayer is the current ILayer;IFeatureClass oldFeatureClass = featureLayer.FeatureClass;IPropertySet propertySet = new PropertySetClass();propertySet.SetProperty("DATABASE", "C:\usr\Desktop\tmp");IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();try{ IWorkspace workspace = workspaceFactory.Open(propertySet, 0); //I've also tried the following for opening up a workspace: //IWorkspace workspace = workspaceFactory.OpenFromFile("C:\usr\Desktop\tmp", 0); IFeatureWorkspace fWork = (IFeatureWorkspace)workspace; //program hits exception on line below IFeatureDataset newFeatureClass = fWork.OpenFeatureDataset("New_Shapefile"); IMapAdmin2 mapAdmin2 = (IMapAdmin2)map; featureLayer.FeatureClass = newFeatureClass; mapAdmin2.FireChangeFeatureClass(oldFeatureClass, newFeatureClass); ESRI.ArcGIS.ArcMapUI.IContentsView contentsView = ArcMap.Document.CurrentContentsView; contentsView.Refresh(null);}catch (Exception e){ ErrorMessage("uh oh something went wrong :(", e);}This code was based off of: http://edndoc.esri.com/arcobjects/9...FeatureWorkspace_OpenFeatureClass_Example.htm



أكثر...
 
أعلى