ArcGIS Pro 3.7 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 Function GetItems() As IEnumerable(Of Item)
    public IEnumerable<Item> GetItems()

    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"));
      //Note: Needs QueuedTask to run
      IEnumerable<Item> folderContents = folderConnection.GetItems();
    }
    Obtaining Geodatabase from Project Item
    {
      await QueuedTask.Run(() =>
      {
        IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
    
        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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also