My implementation of IDataset.Copy continues to crash and I cannot figure out why. The program attempts to copy a shapefile from a temporary folder in one directory to a final folder in another directory. Here is the relevant code, where strOutVoronoiPath is a filepath containing the destination folder and g_temporary is a filepath containing the temporary folder:
//create a shapefile workspace factory ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pSWSF = new ShapefileWorkspaceFactoryClass(); //create a temporary IWorkspace from Shapefile IWorkspaceFactory object ESRI.ArcGIS.Geodatabase.IWorkspace pTempWSP; pTempWSP = pSWSF.OpenFromFile(g_tempFolder, 0); //create a final IWorkspace from Shapefile IWorkspaceFactory object ESRI.ArcGIS.Geodatabase.IWorkspace pFinalWSP; pFinalWSP = pSWSF.OpenFromFile(strOutVoronoiPath, 0); //create a temporary IFeatureWorkspace from Shapefile IWorkspaceFactory object ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pTempFWS; pTempFWS = (IFeatureWorkspace)pSWSF.OpenFromFile(g_tempFolder, 0); //create a final IFeatureWorkspace from Shapefile IWorkspaceFactory object ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pFinalFWS; pFinalFWS = (IFeatureWorkspace)pSWSF.OpenFromFile(strOutVoronoiPath, 0); //Some code goes here where I do some casting and operations //to produce a shapefile inside the temporary folder. I now have //a shapefile I want in temporary folder (at g_tempfolder, which is a string //filepath) and I want to copy it over to a final folder at strOutVoronoiPath //I have taken this shapefile and stored the data from it inside an IFeatureClass. //called pFeatureClass. The following code attempts to take the feature class data and //cast it into IDataset, from which I call IDataset.Copy. The program crashes //on the final line, where I invoke the pDs.Copy() method. pFeatureClass.FeatureClass = pTempFWS.OpenFeatureClass(strOutVoronoiFile); pDs = (IDataset)pFeatureClass; //cast the feature class into a dataset pDs.Copy(strOutVoronoiFile, (IWorkspace)pFinalFWS);
I'm thinking I might have cast something wrong in the final three lines of code?