ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Core Namespace / Item Class / GetItems Method
Example

In This Topic
    GetItems Method (Item)
    In This Topic
    Browses the contents of an item. Returns a snapshot collection of of the item's children. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public IEnumerable<Item> GetItems()
    Public Function GetItems() As IEnumerable(Of Item)

    Return Value

    Returns an enumerable collection of items
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks

    For example, returns a list of all the feature datasets, feature classes, tables and so on within a database. Or, returns a list of all the subfolders and other items within a folder.

    Example
    Get Project Items by ProjectItem type
    /// Get all the items that can be accessed from a folder connection. The items immediately 
    /// contained by a folder, that is, the folder's children, are returned including folders
    /// and individual items that can be used in ArcGIS Pro. This method does not return all 
    /// items contained by any sub-folder that can be accessed from the folder connection.
    FolderConnectionProjectItem folderConnection = Project.Current.GetItems<FolderConnectionProjectItem>()
                                                        .FirstOrDefault((folder => folder.Name.Equals("Data")));
    await QueuedTask.Run(() =>
    {
      IEnumerable<Item> folderContents = folderConnection.GetItems();
    });
    Obtaining Geodatabase from Project Item
    public async Task ObtainingGeodatabaseFromProjectItem()
    {
      IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
    
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        foreach (GDBProjectItem gdbProjectItem in gdbProjectItems)
        {
          using (Datastore datastore = gdbProjectItem.GetDatastore())
          {
            //Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore
            if (datastore is UnknownDatastore)
              continue;
    
            Geodatabase geodatabase = datastore as Geodatabase;
            // Use the geodatabase.
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also