Closed sunzechang closed 5 years ago
#include <string>
#include <iostream>
#include <fstream>
#include <FileGDBAPI.h>
using namespace std;
using namespace FileGDBAPI;
int main()
{
// Open the geodatabase.
fgdbError hr;
wstring errorText;
Geodatabase geodatabase;
if ((hr = OpenGeodatabase(L"C:/FileGDB_API_Test/OpenTable/TemplateData_Protected.gdb", geodatabase)) != S_OK)
{
wcout << "An error occurred while opening the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
// Test GetChildDatasets
wcout << "Test GetChildDatasets:" << endl;
std::vector<std::wstring> childList;
// if ((hr = geodatabase.GetChildDatasets(L"\\World", L"Feature Class", childList)) != S_OK)
if ((hr = geodatabase.GetChildDatasets(L"\\", L"", childList)) != S_OK)
{
wcout << "An error occurred while getting the child datasets." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
for (size_t i = 0; i < childList.size(); i++)
{
wcout << childList[i] << endl;
}
// Close the geodatabase
if ((hr = CloseGeodatabase(geodatabase)) != S_OK)
{
wcout << "An error occurred while closing the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
return 0;
}
If I dont Know the names of datasets,how do I get datasets