Public Sub SetDefaultGeoDatabasePath( _ ByVal defaultGeoDatabase As String _ )
public void SetDefaultGeoDatabasePath( string defaultGeoDatabase )
Parameters
- defaultGeoDatabase
- The full path to the geodatabase that will be used
Public Sub SetDefaultGeoDatabasePath( _ ByVal defaultGeoDatabase As String _ )
public void SetDefaultGeoDatabasePath( string defaultGeoDatabase )
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
| System.ArgumentException | input path cannot be resolved as default geodatabase. |
A project is required to have a default geodatabase. The default geodatabase is used to store spatial datasets and stand-alone tables created by geoprocessing tools. It will also store geodatabase schema items associated with layer templates or schema-only layer packages that are added to a map.
When a project is created, a file geodatabase (.gdb) is created in the home folder of the new project and set as the project's default geodatabase. Once a project has been created, the default geodatabase can be set to another existing geodatabase; providing the geodatabase has already been added as a geodatabase item to the project. Note that changing the default geodatabase does not move or copy any items from the previous default geodatabase to the new one.
The ArcGIS Pro application settings may specify a geodatabase that should always be used as the default geodatabase. Anyone using the project is expected to have write access to and appropriate permissions in that geodatabase. If a project uses a file geodatabase as the default geodatabase and the file geodatabase is not available in the specified location, a file geodatabase will be created accordingly to satisfy the default geodatabase path.
At this time, only file geodatabases can be used as a project's default geodatabase.
{
//Create a new GDB item and add it to the project
if (ItemFactory.Instance.Create(newGDDItemPath) is not IProjectItem newGDBItem)
{
// could not create the item
return;
}
var success = Project.Current.AddItem(newGDBItem);
//make the newly added GDB item the default
if (success)
Project.Current.SetDefaultGeoDatabasePath(newGDDItemPath);
//Now remove the old item
if (Project.Current.GetItems<Item>().FirstOrDefault(i => i.Path == oldGDBItemPath) is not IProjectItem oldGDBItem)
{
// could not find the item
return;
}
var removeSuccess = Project.Current.RemoveItem(oldGDBItem);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)