ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data Namespace / FileSystemDatastore Class / OpenDataset<T> Method
The type of dataset to open.
The name of the dataset to open.
Example

In This Topic
    OpenDataset<T> Method (FileSystemDatastore)
    In This Topic
    Gets a specific Dataset instance associated with name of type T in the file-system data store. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public T OpenDataset<T>( 
       string name
    )
    where T: Dataset
    Public Function OpenDataset(Of T As Dataset)( _
       ByVal name As String _
    ) As T

    Parameters

    name
    The name of the dataset to open.

    Type Parameters

    T
    The type of dataset to open.

    Return Value

    A specific Dataset instance corresponding to type T.
    Exceptions
    ExceptionDescription

    No valid file-system data store has been opened prior to calling this operation.

    -or-

    The dataset type corresponding to T is not supported (see DatasetType).

    name is null or an empty string.
    A geodatabase-related exception has occurred. For example, the name is invalid.
    Example
    Opening a FeatureClass from a ShapeFile Datastore
    {
      await QueuedTask.Run(() =>
      {
        FileSystemConnectionPath fileConnection = new FileSystemConnectionPath(new Uri("path\\to\\folder\\containing\\shapefiles"),
            FileSystemDatastoreType.Shapefile);
        using (FileSystemDatastore shapefile = new FileSystemDatastore(fileConnection))
        {
          FeatureClass taxLotsFeatureClass = shapefile.OpenDataset<FeatureClass>("TaxLots");
    
          // Can use the .shp extension, but its not needed.
          FeatureClass manHolesFeatureClass = shapefile.OpenDataset<FeatureClass>("ManHoles.shp");
    
          Table taxDetailsTableWithoutExtension = shapefile.OpenDataset<Table>("TaxDetails");
          Table taxDetailsTable = shapefile.OpenDataset<Table>("TaxDetails.dbf");
        }
      });
    }
    Opening a CAD Datastore
    {
      await QueuedTask.Run(() =>
      {
        FileSystemConnectionPath fileConnection = new FileSystemConnectionPath(new Uri("path\\to\\folder\\containing\\CAD"), FileSystemDatastoreType.Cad);
        using (FileSystemDatastore cadDatastore = new FileSystemDatastore(fileConnection))
        {
          //Note: Extension is required
          FeatureClass cadDataset = cadDatastore.OpenDataset<FeatureClass>("hatchplayboundaries.dwg");
    
          // Take note of the pattern for referencing a feature class.
          FeatureClass cadfeatureClass = cadDatastore.OpenDataset<FeatureClass>("hatchplayboundaries.dwg:Polyline");
    
          int numRows = 0;
          using (RowCursor cursor = cadfeatureClass.Search())
          {
            while (cursor.MoveNext())
            {
              numRows++;
            }
          }
        }
      });
    }
    Open raster dataset in a folder
    {
      // Create a FileSystemConnectionPath using the folder path.
      FileSystemConnectionPath connectionPath = new(new System.Uri(@"C:\Temp"), FileSystemDatastoreType.Raster);
      // Create a new FileSystemDatastore using the FileSystemConnectionPath.
      FileSystemDatastore dataStore = new(connectionPath);
      // Open the raster dataset.
      fileRasterDataset = dataStore.OpenDataset<RasterDataset>("Sample.tif");
    }
    Open a TIN Dataset
    {
      await QueuedTask.Run(() =>
      {
        string path = @"d:\Data\Tin";
        var fileConnection = new FileSystemConnectionPath(new Uri(path), FileSystemDatastoreType.Tin);
    
        using (FileSystemDatastore dataStore = new FileSystemDatastore(fileConnection))
        {
          // TIN is in a folder at d:\Data\Tin\TinDataset
    
          string dsName = "TinDataset";
    
          using (var dataset = dataStore.OpenDataset<ArcGIS.Core.Data.Analyst3D.TinDataset>(dsName))
          {
            //Do something with the dataset
          }
        }
      });
    }
    Edit an existing TIN
    {
      string tinPath = "C:\\Tin"; //original TIN path
      // Create an instance of TinEditor from an existing TinDataset
      tinEditor = new TinEditor(tinDataset);
      int numNodes = tinDataset.GetNodeCount();  // numNodes = 10
      tinEditor.AddPointZ(pointZ, 7);
    
      // Calling SaveEdits modifies the existing TIN
      tinEditor.SaveEdits();
      numNodes = tinDataset.GetNodeCount();  // numNodes = 11
    
      // Adding twenty points
      tinEditor.AddMassPoints(points, 10, 112.5);
    
      // Calling SaveAs creates a new TIN on disk, and
      // the tin editor points to the new TIN.
      string tinPath2 = "C:\\Tin2";
      tinEditor.SaveAs(tinPath2, true);
    
      tinEditor.StopEditing(true);
      var connection = new FileSystemConnectionPath(new Uri(Path.GetDirectoryName(tinPath2)), FileSystemDatastoreType.Tin);
      using (FileSystemDatastore dataStore = new FileSystemDatastore(connection))
      {
        // See https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-3D-Analyst-Data#working-with-tin-data
        TinDataset tinDataset2 = dataStore.OpenDataset<ArcGIS.Core.Data.Analyst3D.TinDataset>(Path.GetFileName(tinPath2));
        numNodes = tinDataset2.GetNodeCount(); // numNodes = 31
      }
    
      // The edits still show up in the original TIN while it is in memory, but if you open it
      // again you will see that it only has the edits that were saved before SaveAs was called.
      numNodes = tinDataset.GetNodeCount(); // numNodes = 31
      var connection2 = new FileSystemConnectionPath(new Uri(Path.GetDirectoryName(tinPath)), FileSystemDatastoreType.Tin);
      using (FileSystemDatastore dataStore = new FileSystemDatastore(connection))
      {
        // See https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-3D-Analyst-Data#working-with-tin-data
        tinDataset = dataStore.OpenDataset<ArcGIS.Core.Data.Analyst3D.TinDataset>(Path.GetFileName(tinPath));
        numNodes = tinDataset.GetNodeCount(); // numNodes = 11
      }
    }
    Open a LAS Dataset
    {
      await QueuedTask.Run(() =>
      {
        string path = @"d:\Data\LASDataset";
        var fileConnection = new FileSystemConnectionPath(new Uri(path), FileSystemDatastoreType.LasDataset);
    
        using (FileSystemDatastore dataStore = new FileSystemDatastore(fileConnection))
        {
          string name = "utrecht_tile.lasd";      // can specify with or without the .lasd extension
    
          using (var dataset = dataStore.OpenDataset<ArcGIS.Core.Data.Analyst3D.LasDataset>(name))
          {
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also