I've been trying to open a shapefile as a workspace in ArcObjects C++ 10. I've been trying to use this sample as a guide to go by but I can't seem to open my file. (http://help.arcgis.com/en/sdk/10.0/arcobjects_cpp/conceptualhelp/index.html#/Simplify_feature_geometry_for_a_shapefile/0001000000z4000000/)
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(0);
ESRI_SET_VERSION(esriArcGISDesktop);
CComBSTR srcPath;
char path[] = "C:/points/Points_10000.shp";
HRESULT hr = GetParentDirFromFullPath(path, &srcPath);
CComBSTR targetWorkspacePath = L"C:\\Users\\matt.moyles\\Documents\\Visual Studio 2008\\Projects\\PointBenchmarksStandalone\\Debug";
IWorkspaceFactoryPtr sourceWorkspaceFactory(CLSID_ShapefileWorkspaceFactory);
IWorkspacePtr sourceWorkspace;
hr = sourceWorkspaceFactory->OpenFromFile(srcPath, NULL, &sourceWorkspace);
if( FAILED(hr) || sourceWorkspace == 0 )
{
std::wcerr << L"Couldn't open workspace " << (BSTR) srcPath << std::endl;
return 1;
}
ShutdownApp();
CoUninitialize();
return 0;
}
This line sourceWorkspaceFactory->OpenFromFile(srcPath, NULL, &sourceWorkspace); is not returning the IWorkspace. Any help would be appreciated, I've been stuck for a few hours now.