ProSnippets Content - Esri/arcgis-pro-sdk GitHub Wiki
Language: C#
Subject: Content
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: Esri, http://www.esri.com
Date: 11/18/2026
ArcGIS Pro: 3.8
IDE: Visual Studio 2026, Visual Studio Code
Dialogs
OpenItemDialog
// Variables not used in samplesOpenItemDialogselectItemDialog=new();// in #region BrowseDialogItems// Adds a single item to a mapOpenItemDialogaddToMapDialog=new(){Title="Add To Map",InitialLocation=@"C:\Data\NewYork\Counties\Erie\Streets",Filter=ItemFilters.Composite_AddToMap};
Show OpenItemDialog
OpenItemDialogaddToProjectDialog=new(){Title="Add To Project",InitialLocation=@"C:\Data\NewYork\Counties\Maps",MultiSelect=true,Filter=ItemFilters.Composite_Maps_Import};bool?ok=addToProjectDialog.ShowDialog();if(ok==true){IEnumerable<Item>selectedItems=addToProjectDialog.Items;foreach(ItemselectedIteminselectedItems){MapFactory.Instance.CreateMapFromItem(selectedItem);}}
OpenItemDialogaddToProjectDialog=new(){Title="Add To Project",MultiSelect=true,Filter=ItemFilters.Composite_Maps_Import};bool?ok=addToProjectDialog.ShowDialog();if(ok==true){IEnumerable<Item>selectedDialogItems=addToProjectDialog.Items;foreach(ItemselectedDialogIteminselectedDialogItems){MapFactory.Instance.CreateMapFromItem(selectedDialogItem);}}
Retrieving Project Items
Get MapProjectItems
// not to be included in sample regionsvarprojectFolderConnection=Project.Current.GetItems<FolderConnectionProjectItem>().First();// Get all the maps in a projectIEnumerable<MapProjectItem>projectMaps=Project.Current.GetItems<MapProjectItem>();
Get FolderConnectionProjectItems
// Get all the folder connections in a projectIEnumerable<FolderConnectionProjectItem>projectFolders=Project.Current.GetItems<FolderConnectionProjectItem>();// use projectFolders;
Get ServerConnectionProjectItems
// Get all the server connections in a projectIEnumerable<ServerConnectionProjectItem>projectServers=Project.Current.GetItems<ServerConnectionProjectItem>();// use projectServers;
Get LocatorConnectionProjectItems
// Get all the locator connections in a projectIEnumerable<LocatorsConnectionProjectItem>projectLocators=Project.Current.GetItems<LocatorsConnectionProjectItem>();// use projectLocators;
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.FolderConnectionProjectItemfolderConnection=Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(folder =>folder.Name.Equals("Data"));IEnumerable<Item>folderContents=awaitQueuedTask.Run(()=>folderConnection.GetItems());
Working with Project Items
Add Folder to Project as IProjectItem
// Add a folder connection to a projectItemfolderToAdd=ItemFactory.Instance.Create(@"C:\Data\Oregon\Counties\Streets");varproject=Project.Current;boolwasAdded=awaitQueuedTask.Run(()=>project.AddItem(folderToAddasIProjectItem));// use wasAdded;
Add GDBProjectItem to Project as IProjectItem
// Add a file geodatabase or a SQLite or enterprise database connection to a projectItemgdbToAdd=folderToAdd.GetItems().FirstOrDefault(folderItem =>folderItem.Name.Equals("CountyData.gdb"));varproject=Project.Current;varaddedGeodatabase=awaitQueuedTask.Run(()=>project.AddItem(gdbToAddasIProjectItem));// use addedGeodatabase;
Remove FolderConnection From Project
// Remove a folder connection from a project; the folder stored on the local disk// or the network is not deletedvarproject=Project.Current;awaitQueuedTask.Run(()=>{boolresult=false;FolderConnectionProjectItemfolderToRemove=project.GetItems<FolderConnectionProjectItem>().FirstOrDefault(folder =>folder.Name.Equals("Data"));if(folderToRemove!=null){result=project.RemoveItem(folderToRemoveasIProjectItem);}// use result});
Remove Map From Project
// Remove a map from a project; the map is deletedIProjectItemmapToRemove=Project.Current.GetItems<MapProjectItem>().FirstOrDefault(map =>map.Name.Equals("OldStreetRoutes"));varproject=Project.Current;varremovedMapProjectItemResult=awaitQueuedTask.Run(()=>project.RemoveItem(mapToRemove));// Use removedMapProjectItemResult
Importing Maps To Project
// Import a mxdItemmxdToImport=ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd");varproject=Project.Current;varaddedMxd=awaitQueuedTask.Run(()=>project.AddItem(mxdToImportasIProjectItem));// Add map packageItemmapPackageToAdd=ItemFactory.Instance.Create(@"c:\Data\Map.mpkx");varaddedMapPackage=awaitQueuedTask.Run(()=>project.AddItem(mapPackageToAddasIProjectItem));// Add an exported Pro mapItemproMapToAdd=ItemFactory.Instance.Create(@"C:\ExportedMaps\Election\Districts.mapx");varaddedMapProjectItem=awaitQueuedTask.Run(()=>project.AddItem(proMapToAddasIProjectItem));
Create An Item
ItemmxdItem=ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd");// use mxdItem;
Create A PortalItem
// Creates an Item from an existing portal item base on its IDstringportalItemID="9801f878ff4a22738dff3f039c43e395";ItemportalItem=ItemFactory.Instance.Create(portalItemID,ItemFactory.ItemType.PortalItem);// use portalItem;
Create A PortalFolder
// Creates an Item from an existing portal folder base on its IDstringportalFolderID="39c43e39f878f4a2279838dfff3f0015";ItemportalFolder=ItemFactory.Instance.Create(portalFolderID,ItemFactory.ItemType.PortalFolderItem);// use portalFolder;
//cast ICatalogWindow to ArcGIS.Desktop.Framework.Contracts.DockPanevarcatalogWindow=Project.GetCatalogPane()asDockPane;//Activate itcatalogWindow.Activate();
Get the catalog content type currently being shown
//Gets the Catalog panevarcatalogWindow=Project.GetCatalogPane()asICatalogWindow;varcatContentType=catalogWindow.GetCurrentContentType();// use catContentType;
Set the catalog content type
//Gets the Catalog panevarcatalogWindow=Project.GetCatalogPane()asICatalogWindow;if(!catalogWindow.IsActiveWindow){//catalog dockpane must be the active window}//Change the content to whatever is the next tabvarcatContentType=(int)catalogWindow.GetCurrentContentType();catContentType++;if(catContentType>(int)CatalogContentType.Favorites){catContentType=(int)CatalogContentType.Project;}//Must be on the UI - no QueuedTask!catalogWindow.SetContentTypeAsync((CatalogContentType)catContentType);
Get the secondary portal catalog content
//Gets the Catalog panevarcatalogWindow=Project.GetCatalogPane()asICatalogWindow;varcatContentType=catalogWindow.GetCurrentContentType();//Is Portal the content type?if(catContentType==CatalogContentType.Portal){//check what is the portal content type being shown...varsecondaryContentType=catalogWindow.GetCurrentSecondaryPortalContentType();//TODO use secondary portal content type...}
Set the secondary portal catalog content
//Gets the Catalog panevarcatalogWindow=Project.GetCatalogPane()asICatalogWindow;if(!catalogWindow.IsActiveWindow){//catalog dockpane must be the active window}varcatContentType=catalogWindow.GetCurrentContentType();//Is portal content being shown?if(catContentType==CatalogContentType.Portal){//check what is the portal content type being shown...varportalContentType=(int)catalogWindow.GetCurrentSecondaryPortalContentType();//advance to the next tabportalContentType++;if(portalContentType>(int)CatalogSecondaryPortalContentType.LivingAtlas){portalContentType=(int)CatalogSecondaryPortalContentType.UserContent;}//set the secondary portal content type//Must be on the UI - no QueuedTask!catalogWindow.SetSecondaryPortalContentTypeAsync((CatalogSecondaryPortalContentType)portalContentType);}
Geodatabase Content
Geodatabase Content from Browse Dialog
varopenDlg=newOpenItemDialog{Title="Select a Feature Class",InitialLocation=@"C:\Data",MultiSelect=false,BrowseFilter=BrowseProjectFilter.GetFilter(ItemFilters.GeodatabaseItems_All)};//show the browse dialogbool?ok=openDlg.ShowDialog();if(!ok.HasValue||openDlg.Items.Count==0){// nothing selected, leave}varmapView=MapView.Active;awaitQueuedTask.Run(()=>{// get the itemvaritem=openDlg.Items.First();// see if the item has a datasetif(ItemFactory.Instance.CanGetDataset(item)){// get itusingvards=ItemFactory.Instance.GetDataset(item);// access some propertiesvarname=ds.GetName();varpath=ds.GetPath();// if it's a featureclassif(dsisFeatureClassfc){// create a layervarfeatureLayerParams=newFeatureLayerCreationParams(fc){MapMemberIndex=0};varlayer=LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams,mapView.Map);// continue}}});
Geodatabase Content from Catalog selection
// subscribe to eventProjectWindowSelectedItemsChangedEvent.Subscribe(async args =>{if(args.IProjectWindow.SelectionCount>0){// get the first selected itemvarselectedItem=args.IProjectWindow.SelectedItems.First();varmapView=MapView.Active;awaitQueuedTask.Run(()=>{// datasetTypevardataType=ItemFactory.Instance.GetDatasetType(selectedItem);// get the dataset Definitionif(ItemFactory.Instance.CanGetDefinition(selectedItem)){usingvardef=ItemFactory.Instance.GetDefinition(selectedItem);if(defisFeatureClassDefinitionfcDef){varoidField=fcDef.GetObjectIDField();varshapeField=fcDef.GetShapeField();varshapeType=fcDef.GetShapeType();}elseif(defisArcGIS.Core.Data.Parcels.ParcelFabricDefinitionpfDef){stringver=pfDef.GetSchemaVersion();boolenabled=pfDef.GetTopologyEnabled();}}// get the datasetif(ItemFactory.Instance.CanGetDataset(selectedItem)){usingvards=ItemFactory.Instance.GetDataset(selectedItem);if(dsisFeatureDatasetfds){// open featureclasses within the feature dataset// var fcPoint = fds.OpenDataset<FeatureClass>("Point");// var fcPolyline = fds.OpenDataset<FeatureClass>("Polyline");}elseif(dsisFeatureClassfc){varname=fc.GetName()+"_copy";// createvarfeatureLayerParams=newFeatureLayerCreationParams(fc){Name=name,MapMemberIndex=0};LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams,mapView.Map);}elseif(dsisTabletable){varname=table.GetName()+"_copy";vartableParams=newStandaloneTableCreationParams(table){Name=name};// createStandaloneTableFactory.Instance.CreateStandaloneTable(tableParams,mapView.Map);}}});}});
Favorites
Add a Favorite - Folder
varitemFolder=ItemFactory.Instance.Create(@"d:\data");// is the folder item already a favorite?varfav=FavoritesManager.Current.GetFavorite(itemFolder);if(fav==null){if(FavoritesManager.Current.CanAddAsFavorite(itemFolder)){fav=FavoritesManager.Current.AddFavorite(itemFolder);}}
Insert a Favorite - Geodatabase path
gdbPath="@C:\\myDataFolder\\myData.gdb";varitemGDB=ItemFactory.Instance.Create(gdbPath);// is the item already a favorite?varfavorite=FavoritesManager.Current.GetFavorite(itemGDB);// no; add it with IsAddedToAllNewProjects set to trueif(favorite!=null){if(FavoritesManager.Current.CanAddAsFavorite(itemGDB)){FavoritesManager.Current.InsertFavorite(itemGDB,1,true);}}
Add a Favorite - Style project item
StyleProjectItemstyleItem=Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(style =>style.Name=="ArcGIS 3D");if(FavoritesManager.Current.CanAddAsFavorite(styleItem)){// add to favorites with IsAddedToAllNewProjects set to falseFavoritesManager.Current.AddFavorite(styleItem);}
Toggle the flag IsAddedToAllNewProjects for a favorite
varnewItemFolder=ItemFactory.Instance.Create(@"d:\data");// is the folder item already a favorite?varfavorite=FavoritesManager.Current.GetFavorite(newItemFolder);if(favorite!=null){if(favorite.IsAddedToAllNewProjects){FavoritesManager.Current.ClearIsAddedToAllNewProjects(favorite.Item);}else{FavoritesManager.Current.SetIsAddedToAllNewProjects(favorite.Item);}}
Get the set of favorites and iterate
varfavorites=FavoritesManager.Current.GetFavorites();foreach(varfavoriteinfavorites){boolisAddedToAllProjects=favorite.IsAddedToAllNewProjects;// retrieve the underlying item of the favoriteItemitem=favorite.Item;// Item propertiesvaritemType=item.TypeID;varpath=item.Path;// if it's a folder itemif(itemisFolderConnectionProjectItem){}// if it's a geodatabase itemelseif(itemisGDBProjectItem){}// else}
stringgdbXMLMetadataXmlAsString=string.Empty;gdbXMLMetadataXmlAsString=awaitQueuedTask.Run(()=>gdbMetadataItem.GetXml());//check metadata was returnedif(!string.IsNullOrEmpty(gdbXMLMetadataXmlAsString)){//use the metadata}
Item: Set the metadata of an item: SetXML
varxmlMetadata=File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml");awaitQueuedTask.Run(()=>{//Will throw InvalidOperationException if the metadata cannot be changed//so check "CanEdit" firstif(featureClassMetadataItem.CanEdit()){featureClassMetadataItem.SetXml(xmlMetadata);}});
Item: Check the metadata can be edited: CanEdit
boolcanEdit;//Call CanEdit before calling SetXmlcanEdit=awaitQueuedTask.Run(()=>metadataItemToCheck.CanEdit());
Item: Updates metadata with the current properties of the item: Synchronize
Item: Delete certain content from the metadata of the current item: DeleteMetadataContent
ItemfeatureClassWithMetadataItem=ItemFactory.Instance.Create(@"C:\projectBeta\GDBs\regionFive.gdb\SourceFeatureClass");//Delete thumbnail content from item's metadatafeatureClassWithMetadataItem.DeleteMetadataContent(MDDeleteContentOption.esriMDDeleteThumbnail);
Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata
// the input path can be the path to an item with metadata, or a URI to an XML fileawaitQueuedTask.Run(()=>metadataItemImport.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass",MDImportExportOption.esriCurrentMetadataStyle));
Item: Updates metadata with the imported metadata: ImportMetadata
// the input path can be the path to an item with metadata, or a URI to an XML fileawaitQueuedTask.Run(()=>metadataItemImport.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass",MDImportExportOption.esriCustomizedStyleSheet,@"E:\StyleSheets\Import\MyImportStyleSheet.xslt"));
Item: export the metadata of the currently selected item: ExportMetadata
awaitQueuedTask.Run(()=>{metadataItemExport.ExportMetadata(@"E:\Temp\OutputXML.xml",MDImportExportOption.esriCustomizedStyleSheet,MDExportRemovalOption.esriExportExactCopy,@"E:\StyleSheets\Export\MyExportStyleSheet.xslt");// Or export using the current metadata stylemetadataItemExport.ExportMetadata(@"E:\Temp\OutputXML.xml",MDImportExportOption.esriCurrentMetadataStyle,MDExportRemovalOption.esriExportExactCopy);});
Item: Save the metadata of the current item as XML: SaveMetadataAsXML
projectPath=@"https://<userName>.<domain>.com/portal/sharing/rest/content/items/1a434faebbe7424d9982f57d00223baa";stringdocVer=string.Empty;// A portal project path looks like this://@"https://<ServerName>.<Domain>.com/portal/sharing/rest/content/items/1a434faebbe7424d9982f57d00223baa";//A local project path looks like this://@"C:\Users\<UserName>\Documents\ArcGIS\Projects\MyProject\MyProject.aprx";//Check if the project can be openedif(Project.CanOpen(projectPath,outdocVer)){//Open the projectProject.OpenAsync(projectPath);}else//The project cannot be opened{//One possible reason: If the project is a portal project, the active portal must match the portal of the project//Check if this is a portal projectboolisPortalProject=Uri.TryCreate(projectPath,UriKind.Absolute,outUriuriResult)&&(uriResult.Scheme==Uri.UriSchemeHttp||uriResult.Scheme==Uri.UriSchemeHttps);if(isPortalProject){//Parse the project path to get the portalvaruri=newUri(projectPath);varportalUrlOfProjectToOpen=$"{uri.Scheme}://{uri.Host}/portal/";//Get the current active portalvaractivePortal=ArcGISPortalManager.Current.GetActivePortal();//Compare to see if the active Portal is the same as the portal of the projectboolisSamePortal=activePortal!=null&&activePortal.PortalUri.ToString()==portalUrlOfProjectToOpen;if(!isSamePortal)//not the same.{//Set new active portal to be the portal of the project//Find the portal to sign in with using its Uri...varprojectPortal=ArcGISPortalManager.Current.GetPortal(newUri(portalUrlOfProjectToOpen,UriKind.Absolute));boolreturnAfterSignIn=awaitQueuedTask.Run(()=>{if(!projectPortal.IsSignedOn()){//Calling "SignIn" will trigger the OAuth popup if your credentials are//not cached (eg from a previous sign in in the session)if(projectPortal.SignIn().success){//Set this portal as my active portalArcGISPortalManager.Current.SetActivePortal(projectPortal);returntrue;}}//Set this portal as my active portalArcGISPortalManager.Current.SetActivePortal(projectPortal);returnfalse;});if(returnAfterSignIn)return;//Now try opening the project againif(Project.CanOpen(projectPath,outdocVer)){Project.OpenAsync(projectPath);}else{System.Diagnostics.Debug.WriteLine("The project cannot be opened.");}}else//The portals are the same. So the problem could be something else - permissions, portal is down?{System.Diagnostics.Debug.WriteLine("The project cannot be opened.");}}else//Project is on disk and cannot be opened.{System.Diagnostics.Debug.WriteLine("The project cannot be opened.");}}
Determine if the project is a portal project from a project's path
projectPath=Project.Current.Url;// A portal project path looks like this://@"https://<ServerName>.<Domain>.com/portal/sharing/rest/content/items/1a434faebbe7424d9982f57d00223baa";//A local project path looks like this://@"C:\Users\<UserName>\Documents\ArcGIS\Projects\MyProject\MyProject.aprx";boolisPortalProject=Uri.TryCreate(projectPath,UriKind.Absolute,outUriuriResult)&&(uriResult.Scheme==Uri.UriSchemeHttp||uriResult.Scheme==Uri.UriSchemeHttps);if(isPortalProject){System.Diagnostics.Debug.WriteLine("This is a portal project");}else{System.Diagnostics.Debug.WriteLine("This is not a portal project");}// Use isPortalProject;
Determine if the project is a portal project from a project object
varisPortalProject=Project.Current.IsPortalProject;// Use isPortalProject;
Get the portal from a portal project's path
projectPath=Project.Current.Url;// A portal project path looks like this://@"https://<ServerName>.<Domain>.com/portal/sharing/rest/content/items/1a434faebbe7424d9982f57d00223baa";//A local project path looks like this://@"C:\Users\<UserName>\Documents\ArcGIS\Projects\MyProject\MyProject.aprx";//Check if the project is a portal projectboolisPortalProject=Uri.TryCreate(projectPath,UriKind.Absolute,outUriuriResult)&&(uriResult.Scheme==Uri.UriSchemeHttp||uriResult.Scheme==Uri.UriSchemeHttps);if(isPortalProject){//Parse the project path to get the portalvaruri=newUri(projectPath);varfullUri=$"{uri.Scheme}://{uri.Host}/portal/";System.Diagnostics.Debug.WriteLine($"The Url of the project is: {fullUri}");//Now get the ArcGISPortal object from the portal UrivararcgisPortal=ArcGISPortalManager.Current.GetPortal(newUri(fullUri,UriKind.Absolute));System.Diagnostics.Debug.WriteLine($"The portal of the project is: {arcgisPortal.PortalUri}");//Note: You can set the active portal to be the portal of the project. Refer to this snippet: [ArcGISPortalManager: Get a portal and Sign In, Set it Active](ProSnippets-sharing#arcgisportalmanager-get-a-portal-and-sign-in-set-it-active)}
Workflow to open an ArcGIS Pro project using the OpenItemDialog
BrowseProjectFilterportalAndLocalProjectsFilter=new();//A filter to pick projects from the portal//This filter will allow selection of ppkx and portal project items on the portalportalAndLocalProjectsFilter.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_projects_online_proprojects"));//A filter to pick projects from the local machineportalAndLocalProjectsFilter.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_projects"));//Create the OpenItemDialog and set the filter to the one we just createdvaropenDlg=newOpenItemDialog(){Title="Select a Project",MultiSelect=false,BrowseFilter=portalAndLocalProjectsFilter};//Show the dialogvarresult=openDlg.ShowDialog();//Check if the user clicked OK and selected an itembool?ok=openDlg.ShowDialog();if(!ok.HasValue||openDlg.Items.Count==0){return;//nothing selected}varselectedItem=openDlg.Items.FirstOrDefault();//Open the project use the OpenAsync method.
Retrieve a project item from a portal and open it
varprojectPortal=ArcGISPortalManager.Current.GetPortal(newUri(@"https://<serverName>.<domain>.com/portal/",UriKind.Absolute));stringowner=string.Empty;//Get the signed on user nameowner=awaitQueuedTask.Run(()=>projectPortal.GetSignOnUsername());//Get the user content from the portalPortalUserContentuserContent=awaitprojectPortal.GetUserContentAsync(owner);//Get the first portal project itemvarfirstPortalProject=userContent.PortalItems.FirstOrDefault(pi =>pi.PortalItemType==PortalItemType.ProProject);varportalProjectUri=firstPortalProject.ItemUri.ToString();//Check if project can be openedstringdocVer=string.Empty;if(Project.CanOpen(portalProjectUri,outdocVer)){Project.OpenAsync(portalProjectUri);}//Note: If Project.CanOpen returns false, the project cannot be opened. One reason could be// the active portal is not the same as the portal of the project. Refer to the snippet: [Workflow to open an ArcGIS Pro project](ProSnippets-sharing#workflow-to-open-an-arcgis-pro-project)
Retrieve the list of recently opened projects
IReadOnlyList<Tuple<string,string>>result=[];//A list of Tuple instances containing two strings.//The first string: full path to the .aprx. In case of Portal projects,//this is the cached location of the project on the local machine.//Second string: url for portal projectsresult=Project.GetRecentProjectsEx();foreach(varprojectinresult){stringprojectUrl;if(!string.IsNullOrEmpty(project.Item2)){//this is a portal project//UrlprojectUrl=project.Item2;//local cached location of the portal projectprojectPath=project.Item1;}else{//this is a local project//path to local projectprojectPath=project.Item1;}projectName=newFileInfo(project.Item1).Name;}
Project
Create a new project
//Create a new project using Pro's default settingsvardefaultProjectSettings=Project.GetDefaultProjectSettings();varproject=awaitProject.CreateAsync(defaultProjectSettings);// Use project
Create an empty project
//Create an empty project. The project will be created in the default folder//It will be named MyProject1, MyProject2, or similar...varproject=awaitProject.CreateAsync();// Use project
Create a new project with specified name
//Settings used to create a new projectCreateProjectSettingsprojectSettings=new(){//Sets the name of the project that will be created// example: projectName = @"C:\Data\MyProject1\MyProject1.aprx"Name=projectName};//Create the new projectvarproject=awaitProject.CreateAsync(projectSettings);// Use project
Create new project using Pro's default settings
//Get Pro's default project settings.vardefaultProjectSettings=Project.GetDefaultProjectSettings();//Create a new project using the default project settingsvarproject=awaitProject.CreateAsync(defaultProjectSettings);// Use project
New project using a custom template file
//Settings used to create a new projectCreateProjectSettingsprojectSettings=new(){//Sets the project's nameName=projectName,//Path where new project will be stored inLocationPath=@"C:\Data\NewProject",//Sets the project template that will be used to create the new projectTemplatePath=@"C:\Data\MyProject1\CustomTemplate.aptx"};//Create the new projectvarproject=awaitProject.CreateAsync(projectSettings);// Use project
Create a project using template available with ArcGIS Pro
//Settings used to create a new projectCreateProjectSettingsproTemplateSettings=new(){//Sets the project's nameName=projectName,//Path where new project will be stored inLocationPath=@"C:\Data\NewProject",//Select which Pro template you like to useTemplateType=TemplateType.Catalog//TemplateType = TemplateType.LocalScene//TemplateType = TemplateType.GlobalScene//TemplateType = TemplateType.Map};//Create the new projectvarproject=awaitProject.CreateAsync(proTemplateSettings);// Use project
Open an existing project
//Opens an existing project or project package// example: @"C:\Data\MyProject1\MyProject1.aprx"varproject=awaitProject.OpenAsync(projectPath);// Use project
Get the Current project
//Gets the current projectvarproject=Project.Current;// Use project
Get location of current project
//Gets the location of the current project; that is, the path to the current project file (*.aprx)projectPath=Project.Current.URI;// Use projectPath
Get the project's default gdb path
varprojGDBPath=Project.Current.DefaultGeodatabasePath;// Use projGDBPath;
Change the Project's default gdb path
//Create a new GDB item and add it to the projectif(ItemFactory.Instance.Create(newGDDItemPath)is not IProjectItemnewGDBItem){// could not create the itemreturn;}varsuccess=Project.Current.AddItem(newGDBItem);//make the newly added GDB item the defaultif(success){Project.Current.SetDefaultGeoDatabasePath(newGDDItemPath);}//Now remove the old itemif(Project.Current.GetItems<Item>().FirstOrDefault(i =>i.Path==oldGDBItemPath)is not IProjectItemoldGDBItem){// could not find the itemreturn;}varremoveSuccess=Project.Current.RemoveItem(oldGDBItem);
Save project
//Saves the projectvarsuccess=awaitProject.Current.SaveAsync();
Check if project needs to be saved
//The project's dirty state indicates changes made to the project have not yet been saved.boolisProjectDirty=Project.Current.IsDirty;// Use isProjectDirty;
SaveAs project
//Saves a copy of the current project file (*.aprx) to the specified location with the specified file name,//then opens the new project filevarsuccess=awaitProject.Current.SaveAsAsync(newProjectPath);
Close a project
//A project cannot be closed using the ArcGIS Pro API.//A project is only closed when another project is opened, a new one is created, or the application is shutdown.
How to add a new map to a project
//Note: see also MapFactory in ArcGIS.Desktop.Mappingvarmap=awaitQueuedTask.Run(()=>MapFactory.Instance.CreateMap("New Map",MapType.Map,MapViewingMode.Map,Basemap.Oceans));ArcGIS.Desktop.Framework.FrameworkApplication.Panes.CreateMapPaneAsync(map);
Get Recent Projects
varrecentProjects=Project.GetRecentProjects();// Use recentProjects;
Clear Recent Projects
Project.ClearRecentProjects();
Remove a Recent Project
Project.RemoveRecentProject(projectPath);
Get Pinned Projects
varpinnedProjects=Project.GetPinnedProjects();// Use pinnedProjects;
Add a folder connection item to the current project
//Adding a folder connection//Create the folder connection project itemvaritem=ItemFactory.Instance.Create(folderPath)asIProjectItem;varfolder=awaitQueuedTask.Run(()=>Project.Current.AddItem(item)?itemasFolderConnectionProjectItem:null);
Add a geodatabase item to the current project
//Adding a Geodatabase:awaitQueuedTask.Run(()=>{//Create the File GDB project itemvaritem=ItemFactory.Instance.Create(gdbPath)asIProjectItem;varnewlyAddedGDB=Project.Current.AddItem(item)?itemasGDBProjectItem:null;});
varproject=Project.Current;IEnumerable<MapProjectItem>newMapItemsContainer=project.GetItems<MapProjectItem>();awaitQueuedTask.Run(()=>{foreach(varmpinnewMapItemsContainer){//Do Something with the map. For Example:MapmyMap=mp.GetMap();}});
Get a specific MapProjectItem
MapProjectItemmapProjItem=Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item =>item.Name.Equals("EuropeMap"));// Use mapProjItem;
Get all StyleProjectItems
IEnumerable<StyleProjectItem>newStyleItemsContainer=null;newStyleItemsContainer=Project.Current.GetItems<StyleProjectItem>();foreach(varstyleIteminnewStyleItemsContainer){//Do Something with the style.}
IEnumerable<GDBProjectItem>newGDBItemsContainer=null;newGDBItemsContainer=Project.Current.GetItems<GDBProjectItem>();foreach(varGDBIteminnewGDBItemsContainer){//Do Something with the GDB.}
Get a specific GDBProjectItem
GDBProjectItemgdbProjItem=Project.Current.GetItems<GDBProjectItem>().FirstOrDefault(item =>item.Name.Equals("myGDB"));// Use gdbProjItem;
Get all ServerConnectionProjectItems
IEnumerable<ServerConnectionProjectItem>newServerConnections=null;varproject=Project.Current;newServerConnections=project.GetItems<ServerConnectionProjectItem>();foreach(varserverIteminnewServerConnections){//Do Something with the server connection.}
Get a specific ServerConnectionProjectItem
ServerConnectionProjectItemserverProjItem=Project.Current.GetItems<ServerConnectionProjectItem>().FirstOrDefault(item =>item.Name.Equals("myServer"));// Use serverProjItem;
Get all folder connections in a project
//Gets all the folder connections in the current projectvarprojectFolders=Project.Current.GetItems<FolderConnectionProjectItem>();foreach(varFolderIteminprojectFolders){//Do Something with the Folder connection.}
Get a specific folder connection
FolderConnectionProjectItemfolderProjItem=Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(item =>item.Name.Equals("myDataFolder"));// Use folderProjItem;
Remove a specific folder connection
// Remove a folder connection from a project; the folder stored on the local disk or the network is not deletedFolderConnectionProjectItemfolderToRemove=Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(myfolder =>myfolder.Name.Equals("PlantSpecies"));if(folderToRemove!=null){Project.Current.RemoveItem(folderToRemoveasIProjectItem);}
Gets a specific LayoutProjectItem
LayoutProjectItemlayoutProjItem=Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item =>item.Name.Equals("myLayout"));// Use layoutProjItem;
Get all layouts in a project
//Gets all the layouts in the current projectIEnumerable<LayoutProjectItem>projectLayouts=Project.Current.GetItems<LayoutProjectItem>();foreach(varlayoutIteminprojectLayouts){//Do Something with the layout}
Get a specific GeoprocessingProjectItem
//Gets a specific GeoprocessingProjectItem in the current project// example: "myToolbox" is the name of the GeoprocessingProjectItemGeoprocessingProjectItemgpProjItem=Project.Current.GetItems<GeoprocessingProjectItem>().FirstOrDefault(item =>item.Name.Equals("myToolbox"));// Use gpProjItem;
Get all GeoprocessingProjectItems in a project
//Gets all the GeoprocessingProjectItem in the current projectvarGPItems=Project.Current.GetItems<GeoprocessingProjectItem>();foreach(vartbxinGPItems){//Do Something with the toolbox}
Search project for a specific item
List<Item>_mxd=[];//Gets all the folder connections in the current projectvarallFoldersItem=Project.Current.GetItems<FolderConnectionProjectItem>();if(allFoldersItem!=null){//iterate through all the FolderConnectionProjectItems foundforeach(varfolderIteminallFoldersItem){//Search for mxd files in that folder connection and add it to the List<T>//Note:ArcGIS Pro automatically creates and dynamically updates a searchable index as you build and work with projects.//Items are indexed when they are added to a project.//The first time a folder or database is indexed, indexing may take a while if it contains a large number of items.//While the index is being created, searches will not return any results._mxd.AddRange(folderItem.GetItems());}}
Get the Default Project Folder
//Get Pro's default project settings.vardefaultSettings=Project.GetDefaultProjectSettings();vardefaultProjectPath=defaultSettings.LocationPath;// If not set, projects are saved in the user's My Documents\ArcGIS\Projects folder;// this folder is created if it doesn't already exist.defaultProjectPath??=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),@"ArcGIS\Projects");// Use defaultProjectPath;
Refresh the child item for a folder connection Item
varcontentItem=Project.Current.GetItems<FolderConnectionProjectItem>().First();//Check if the MCT is required for Refresh()if(contentItem.IsMainThreadRequired){awaitQueuedTask.Run(()=>contentItem.Refresh());}else{//if item.IsMainThreadRequired returns false, any//thread can be used to invoke Refresh(), though//BackgroundTask is preferred.contentItem.Refresh();//Or, via BackgroundTaskArcGIS.Core.Threading.Tasks.BackgroundTask.Run(()=>contentItem.Refresh(),ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None);}
Get Item Categories
// Get the ItemCategories with which an item is associatedgdb=ItemFactory.Instance.Create(@"E:\CurrentProject\RegionalPolling\polldata.gdb");List<ItemCategory>gdbItemCategories=gdb.ItemCategories;// Use gdbItemCategories;
Using Item Categories
// Browse items using an ItemCategory as a filterIEnumerable<Item>gdbContents=gdb.GetItems();IEnumerable<Item>filteredGDBContents1=gdbContents.Where(item =>item.ItemCategories.OfType<ItemCategoryDataSet>().Any());IEnumerable<Item>filteredGDBContents2=newItemCategoryDataSet().Items(gdbContents);
//GetItems searches project contentvarmap=Project.Current.GetItems<MapProjectItem>().FirstOrDefault(m =>m.Name=="Map1");varlayout=Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(m =>m.Name=="Layout1");varfolders=Project.Current.GetItems<FolderConnectionProjectItem>();varstyle=Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s =>s.Name=="ArcGIS 3D");//Find item uses a catalog path. The path can be to a file or datasetvarfcPath=@"C:\Pro\CommunitySampleData\Interacting with Maps\Interacting with Maps.gdb\Crimes";varpdfPath=@"C:\Temp\Layout1.pdf";varimgPath=@"C:\Temp\AddinDesktop16.png";varfc=Project.Current.FindItem(fcPath);varpdf=Project.Current.FindItem(pdfPath);varimg=Project.Current.FindItem(imgPath);
Select an item in the Catalog pane
//Get the catalog paneIProjectWindowprojectWindow=Project.GetCatalogPane();//or get the active catalog view...//ArcGIS.Desktop.Core.IProjectWindow projectWindow = Project.GetActiveCatalogWindow();//eg Find a toolbox in the projectstringgpName="Interacting with Maps.tbx";vartoolbox=Project.Current.GetItems<GeoprocessingProjectItem>().FirstOrDefault(tbx =>tbx.Name==gpName);//Select it under ToolboxesawaitprojectWindow.SelectItemAsync(toolbox,true,true,null);//null selects it in the first container//Note: Project.Current.GetProjectItemContainer("GP") would get toolbox container...//assume toolbox is also under Folders container. Select it under Folders instead of ToolboxesvarfoldersContainer=Project.Current.ProjectItemContainers.First(c =>c.Path=="FolderConnection");//We must specify the container because Folders comes second (after Toolboxes)awaitprojectWindow.SelectItemAsync(toolbox,true,true,foldersContainer);//Find a map and select itvarmapItem=Project.Current.GetItems<MapProjectItem>().FirstOrDefault(m =>m.Name=="Map");//Map only occurs under "Maps" so the container need not be specifiedprojectWindow.SelectItemAsync(mapItem,true,false,null);
Project Units
Get The Full List of All Available Unit Formats
awaitQueuedTask.Run(()=>{varunit_formats=Enum.GetValues(typeof(UnitFormatType)).OfType<UnitFormatType>().ToList();System.Diagnostics.Debug.WriteLine("All available units\r\n");foreach(varunit_formatinunit_formats){varunits=DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(unit_format);System.Diagnostics.Debug.WriteLine(unit_format.ToString());foreach(vardisplay_unit_formatinunits){varline=$"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}";System.Diagnostics.Debug.WriteLine(line);}System.Diagnostics.Debug.WriteLine("");}});
Get The List of Unit Formats for the Current Project
Get A Specific Default Unit Format for the Current Project
awaitQueuedTask.Run(()=>{//UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance,//UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page//UnitFormatType.Symbol2D, UnitFormatType.Symbol3Dvardefault_unit=DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(UnitFormatType.Distance);// Use default_unit;});
Set a Specific List of Unit Formats for the Current Project
awaitQueuedTask.Run(()=>{//UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance,//UnitFormatType.Direction, UnitFormatType.Location//Get the full list of all available location unitsvarall_units=DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(UnitFormatType.Location);//keep units with an even factory codevarlist_units=all_units.Where(du =>du.UnitCode%2==0).ToList();//set them as the new location unit collection. A new default is not being specified...DisplayUnitFormats.Instance.SetProjectUnitFormats(list_units);//set them as the new location unit collection along with a new defaultDisplayUnitFormats.Instance.SetProjectUnitFormats(list_units,list_units.First());//Note: UnitFormatType.Page, UnitFormatType.Symbol2D, UnitFormatType.Symbol3D//cannot be set.});
Set the Defaults for the Project Unit Formats
awaitQueuedTask.Run(()=>{varunit_formats=Enum.GetValues(typeof(UnitFormatType)).OfType<UnitFormatType>().ToList();foreach(varunit_typeinunit_formats){varcurrent_default=DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_type);//Arbitrarily pick the last unit in each unit format listvarreplacement=DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_type).Last();DisplayUnitFormats.Instance.SetDefaultProjectUnitFormat(replacement);varline=$"{current_default.DisplayName}, {current_default.UnitName}, {current_default.UnitCode}";varline2=$"{replacement.DisplayName}, {replacement.UnitName}, {replacement.UnitCode}";System.Diagnostics.Debug.WriteLine($"Format: {unit_type}");System.Diagnostics.Debug.WriteLine($" Current default: {line}");System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}");}});
Update Unit Formats for the Project
//UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance,//UnitFormatType.Direction, UnitFormatType.Locationvarangle_units=DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Angular);//Edit the display name of each unit - append the abbreviationforeach(varunitinangle_units){unit.DisplayName=$"{unit.DisplayName} ({unit.Abbreviation})";}//apply the changes to the units and set the default to be the first entryDisplayUnitFormats.Instance.SetProjectUnitFormats(angle_units,angle_units.First());//The project must be saved to persist the changes...
//Set the application to use a custom project, home folder, gdb, and toolbox//In each case, the custom _path_ must be set _first_ before//setting the "option". This ensures the application remains//in a consistent state. This is the same behavior as on the Pro UI.if(string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.StartupProjectPath)){ApplicationOptions.GeneralOptions.StartupProjectPath=@"D:\data\usa.aprx";//custom project path first}ApplicationOptions.GeneralOptions.StartupOption=StartProjectMode.WithDefaultProject;//option to use it secondif(string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomHomeFolder)){ApplicationOptions.GeneralOptions.CustomHomeFolder=@"D:\home_folder";//custom home folder first}ApplicationOptions.GeneralOptions.HomeFolderOption=OptionSetting.UseCustom;//option to use it secondif(string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase)){ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase=@"D:\data\usa.gdb";//custom gdb path first}ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption=OptionSetting.UseCustom;//option to use it secondif(string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultToolbox)){ApplicationOptions.GeneralOptions.CustomDefaultToolbox=@"D:\data\usa.tbx";//custom toolbox path first}ApplicationOptions.GeneralOptions.DefaultToolboxOption=OptionSetting.UseCustom;//option to use it second
Set GeneralOptions to Use Defaults
//Default options can be set regardless of the value of the "companion"//path (to a project, folder, gdb, toolbox, etc.). The path value is ignored if//the option setting does not use it. This is the same behavior as on the Pro UI.ApplicationOptions.GeneralOptions.StartupOption=StartProjectMode.ShowStartPage;ApplicationOptions.GeneralOptions.HomeFolderOption=OptionSetting.UseDefault;ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption=OptionSetting.UseDefault;ApplicationOptions.GeneralOptions.DefaultToolboxOption=OptionSetting.UseDefault;//set default option first//path values can (optionally) be set (back) to null if their//"companion" option setting is the default option.if(ApplicationOptions.GeneralOptions.StartupOption!=StartProjectMode.WithDefaultProject){ApplicationOptions.GeneralOptions.StartupProjectPath=null;}if(ApplicationOptions.GeneralOptions.HomeFolderOption==OptionSetting.UseDefault){ApplicationOptions.GeneralOptions.CustomHomeFolder=null;}if(ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption==OptionSetting.UseDefault){ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase=null;}if(ApplicationOptions.GeneralOptions.DefaultToolboxOption==OptionSetting.UseDefault){ApplicationOptions.GeneralOptions.CustomDefaultToolbox=null;}
//Options are mutually exclusive.//Setting ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = true//supersedes any value in ApplicationOptions.DownloadOptions.UnpackPPKXLocation//and will prompt the user on an unpack. The value of//ApplicationOptions.DownloadOptions.UnpackPPKXLocation will be unaffected//and is ignored. This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation=true;//override location//The default location is typically <My Documents>\ArcGIS\Packages//Setting ApplicationOptions.DownloadOptions.UnpackPPKXLocation to any//location overrides ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation//and sets it to false. This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.UnpackPPKXLocation=@"D:\data\for_ppkx";//Or, if ApplicationOptions.DownloadOptions.UnpackPPKXLocation already//contains a valid path, set ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation//explicitly to false to use the UnpackPPKXLocationif(!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackPPKXLocation)){ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation=false;}
Set DownloadOptions for UnpackOther
//UnpackOther settings control unpacking of anything _other than_//a ppkx or aptx. Options are mutually exclusive.//Set ApplicationOptions.DownloadOptions.UnpackOtherLocation explicitly to//toggle ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and//ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false//Note: default is typically <My Documents>\ArcGIS\Packages, _not_ null.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.UnpackOtherLocation=@"D:\data\for_other";//or...to use a location already stored in UnpackOtherLocation as the//default without changing it,//set ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and//ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false//explicitly. This is the same behavior as on the Pro UI.if(!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackOtherLocation)){ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation=false;ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation=false;}//Setting ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to//true overrides any UnpackOtherLocation value and sets//ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation=true;//Setting ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to//true overrides any UnpackOtherLocation value and sets//ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to false.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation=false;
Set DownloadOptions for OfflineMaps
//OfflineMaps settings control where map content that is taken//offline is copied to on the local machine. Options are mutually exclusive.//Set ApplicationOptions.DownloadOptions.OfflineMapsLocation explicitly to//toggle ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and//ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false//Note: default is typically <My Documents>\ArcGIS\OfflineMaps, _not_ null.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.OfflineMapsLocation=@"D:\data\for_offline";//or...to use a location already stored in OfflineMapsLocation as the//default without changing it,//set ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and//ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false//explicitly.if(!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.OfflineMapsLocation)){ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation=false;ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation=false;}//Setting ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to//true overrides any OfflineMapsLocation value and sets//ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation=true;//Setting ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to//true overrides any OfflineMapsLocation value and sets//ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to false.//This is the same behavior as on the Pro UI.ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation=true;
Get/Set Portal Project Options
// access the current optionsvardef_home=ApplicationOptions.GeneralOptions.PortalProjectCustomHomeFolder;vardef_gdb=ApplicationOptions.GeneralOptions.PortalProjectCustomDefaultGeodatabase;vardef_tbx=ApplicationOptions.GeneralOptions.PortalProjectCustomDefaultToolbox;vardeleteOnClose=ApplicationOptions.GeneralOptions.PortalProjectDeleteLocalCopyOnClose;vardef_location=ApplicationOptions.GeneralOptions.PortalProjectDownloadLocation;// set the optionsApplicationOptions.GeneralOptions.PortalProjectCustomHomeFolder=@"E:\data";ApplicationOptions.GeneralOptions.PortalProjectCustomDefaultGeodatabase=@"E:\data\usa.gdb";ApplicationOptions.GeneralOptions.PortalProjectCustomDefaultToolbox=@"E:\data\usa.tbx";ApplicationOptions.GeneralOptions.PortalProjectDeleteLocalCopyOnClose=false;ApplicationOptions.GeneralOptions.PortalProjectDownloadLocation=@"E:\data";