This document is archived and information here might be outdated.  Recommended version.


How to connect to a file geodatabase (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Appendix: ArcObjects in Visual C++ > Samples > Geodatabase > Accessing data > How to connect to a file geodatabase (ArcObjects .NET 10.6 SDK)

How to connect to a file geodatabase


Making a connection to a workspace is the foundation to accessing data. This sample will show you how to connect to a file geodatabase stored in an .gdb file. The example code is a function that takes the path to the File geodatabase as a string and returns a workspace.

How to use

  1. Paste the function in your project.
  2. Call the function from your code.
[VCPP]
// connString should be full path to a .gdb folder, i.e.:
// L"C:\\Data\\Landbase.gdb"
HRESULT openFGDBWorkspace(BSTR connString, IWorkspace **outWorkspace)
{
  IWorkspaceFactoryPtr ipWorkspaceFactory(CLSID_FileGDBWorkspaceFactory);
  return ipWorkspaceFactory->OpenFromFile(connString, NULL, outWorkspace);
}






Development licensing Deployment licensing
Engine Developer Kit Engine