#include <string>
#include <fstream>
#include <iostream>
#include <FileGDBAPI.h>
#include "CSchemas.h"
using namespace std;
using namespace FileGDBAPI;
int main()
{
int iexecuteStatus;
Geodatabase newFGDB;
//1.Create File Geodatabase(path,name,gdb)
iexecuteStatus =CreateFileGDB(L"C:/Temp",L"test1.gdb",newFGDB);
if(iexecuteStatus!=0)
{
wcout<<L"create file geodatabase error!"<<endl;
return -1;
}
return 0;
}
//Create File Geodatabase for Format Convertion
//Author: Hexz
//CreateTime:2011-10-13
//Version:1.0
//Revision:No
int CreateFileGDB(std::wstring filegdbPath,std::wstring filegdbName,Geodatabase& pnewFGDB)
{
fgdbError hr;
wstring errorText;
Geodatabase geodatabase;
wstring fgdb;
fgdb.empty();
fgdb.append(filegdbPath);
fgdb.append(L"/");
fgdb.append(filegdbName);
//Try to delete exist the same filegdb
hr = DeleteGeodatabase(fgdb);
if (hr == S_OK)
{
wcout << "Find the GDB exist,then the origin geodatabase has been deleted" << endl;
}
else if (hr == -2147024893)
{
wcout << "The geodatabase does not exist, no need to delete" << endl;
}
else
{
wcout << "An error occurred while deleting the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
// Create a new geodatabase in the parameter Path.
if ((hr = CreateGeodatabase(fgdb, geodatabase)) != S_OK)
{
wcout << "An error occurred while creating the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
wcout << "The geodatabase has been created." << endl;
return 0;
}
I have used version1.1 ,but vs2010 show the same error!as code paste in the thread.could help my code error? Thanks