ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data Namespace / Geodatabase Class / Geodatabase Constructor / Geodatabase Constructor(FileGeodatabaseConnectionPath)
Holds a valid path to a file geodatabase folder that ends with the .gdb extension.
Example

In This Topic
    Geodatabase Constructor(FileGeodatabaseConnectionPath)
    In This Topic
    Opens a file geodatabase with the specified connectionPath. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    connectionPath
    Holds a valid path to a file geodatabase folder that ends with the .gdb extension.
    Exceptions
    ExceptionDescription
    The path to the geodatabase is invalid or the geodatabase cannot be opened.
    A geodatabase-related exception has occurred.
    This object must be created within the lambda or delegate passed to QueuedTask.Run, or on a compatible STA thread.
    Example
    Opening a File Geodatabase given the path
    public async Task OpenFileGDB()
    {
      try
      {
        await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
        {
          // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase.
          using (
            Geodatabase geodatabase =
              new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb"))))
          {
            // Use the geodatabase.
          }
        });
      }
      catch (GeodatabaseNotFoundOrOpenedException exception)
      {
        // Handle Exception.
      }
    
    }
    
    Open raster dataset in a geodatabase
    // Create a FileGeodatabaseConnectionPath using the path to the gdb. Note: This can be a path to a .sde file.
    FileGeodatabaseConnectionPath geodatabaseConnectionPath = new FileGeodatabaseConnectionPath(new Uri(@"C:\Temp\rasters.gdb"));
    // Create a new Geodatabase object using the FileGeodatabaseConnectionPath.
    Geodatabase geodatabase = new Geodatabase(geodatabaseConnectionPath);
    // Open the raster dataset.
    RasterDataset gdbRasterDataset = geodatabase.OpenDataset<RasterDataset>("sample");
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also