ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core Namespace / IItemFactory Interface / Create Method
Example Version

Create Method (IItemFactory)
Defines the factory create method all factories must implement.
Syntax

Parameters

uri
itemType

Return Value

Example
Add a folder connection item to the current project
//Adding a folder connection
string folderPath = "@C:\\myDataFolder";
var folder = await QueuedTask.Run(() =>
{
  //Create the folder connection project item
  var item = ItemFactory.Instance.Create(folderPath) as IProjectItem;
  //If it is successfully added to the project, return it otherwise null
  return Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null;
});

//Adding a Geodatabase:
string gdbPath = "@C:\\myDataFolder\\myData.gdb";
var newlyAddedGDB = await QueuedTask.Run(() =>
{
  //Create the File GDB project item
  var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem;
  //If it is successfully added to the project, return it otherwise null
  return Project.Current.AddItem(item) ? item as GDBProjectItem : null;
});
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also