public static Task<Project> OpenAsync( string projectUri )
Public Shared Function OpenAsync( _ ByVal projectUri As String _ ) As Task(Of Project)
Parameters
- projectUri
- The full path or URL to the project or project package that will be opened
public static Task<Project> OpenAsync( string projectUri )
Public Shared Function OpenAsync( _ ByVal projectUri As String _ ) As Task(Of Project)
Exception | Description |
---|---|
System.ArgumentNullException | |
System.IO.FileNotFoundException |
ArcGIS Pro can open projects or project packages stored on a local or network computer, portal projects available from an ArcGIS Enterprise portal, and project packages available from an ArcGIS Enterprise portal or ArcGIS Online. Provide a valid file path or URL as appropriate. When a URL is provided, the portal associated with the URL must be the active portal, and you must sign in to the organization unless you are accessing a public project package.
A local cache of the portal project is created in the download location specified by the GeneralOptions settings, then a project file (*.aprx) representing the portal project is opened by ArcGIS Pro.
Alternatively, a project package stored in a portal is downloaded from the portal as determined by the DownloadOptions settings. All project packages are unpacked, then the project file (*.aprx) provided by the package is opened by ArcGIS Pro.
If a project is currently open in ArcGIS Pro, it will be closed before the specified project is opened.
//Opens an existing project or project package await Project.OpenAsync(@"C:\Data\MyProject1\MyProject1.aprx");
//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.
string openProjectPath = @"D\DATA\IGPHistoryItemTestProject\IGPHistoryItemTestProject.aprx"; await Project.OpenAsync(openProjectPath); MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map", StringComparison.CurrentCultureIgnoreCase)); var map = await QueuedTask.Run(() => mapProjItem.GetMap()); var ftrLayer = map.Layers[0] as FeatureLayer; string tool1 = "management.GetCount"; var args1 = Geoprocessing.MakeValueArray(ftrLayer); var env = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true); GPExecuteToolFlags executeFlags = GPExecuteToolFlags.AddToHistory; var t = await Geoprocessing.ExecuteToolAsync(tool1, args1, env, null, null, executeFlags); IEnumerable<IGPHistoryItem> hisItems = Project.Current.GetProjectItemContainer(Geoprocessing.HistoryContainerKey) as IEnumerable<IGPHistoryItem>; String hitemID = ""; String hitemToolPath = ""; IGPResult hitemGPResult = null; DateTime hitemTimeStamp; foreach (var hitem in hisItems) { // common IGPHistoryItem and Item properties hitemID = (hitem as Item).ID; hitemToolPath = hitem.ToolPath; hitemGPResult = hitem.GPResult; hitemTimeStamp = hitem.TimeStamp; }
Target Platforms: Windows 11, Windows 10