ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.TaskAssistant Namespace / TaskAssistantFactory Class / ExportTaskItemAsync Method
A unique identifier used to identify the project task item to export. This identifier is the return value from the OpenTaskFileAsync(String) or OpenTaskFileAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.
The path on disk where the .esriTask file is to be saved.
Example

In This Topic
    ExportTaskItemAsync Method
    In This Topic
    Exports the specified task item to an ArcGIS Pro .esriTasks file at the defined location.
    Syntax
    public Task<string> ExportTaskItemAsync( 
       Guid taskItemGuid,
       string path
    )
    Public Function ExportTaskItemAsync( _
       ByVal taskItemGuid As Guid, _
       ByVal path As String _
    ) As Task(Of String)

    Parameters

    taskItemGuid
    A unique identifier used to identify the project task item to export. This identifier is the return value from the OpenTaskFileAsync(String) or OpenTaskFileAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.
    path
    The path on disk where the .esriTask file is to be saved.

    Return Value

    A Task returning the full path of the exported file.
    Exceptions
    ExceptionDescription
    Error exporting the task item. For example the path is invalid.
    This must be called on the UI thread.
    Example
    Export a Task Item
    // get the first project task item
    var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
    // if there isn't a project task item, return
    if (taskItem == null)
      return;
    
    try
    {
      // export the task item to the c:\Temp folder
      string exportFolder = @"c:\temp";
      //At 2.x -
      //string fileName = await TaskAssistantModule.ExportTaskAsync(taskItem.TaskItemGuid, exportFolder);
      string fileName = await TaskAssistantFactory.Instance.ExportTaskItemAsync(taskItem.TaskItemGuid, exportFolder);
      ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Task saved to " + fileName);
    }
    catch (ExportTaskException e)
    {
      ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error saving task " + e.Message);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also