ArcGIS Pro 2.6 API Reference Guide
ExportTaskAsync Method
Example 

ArcGIS.Desktop.TaskAssistant Namespace > TaskAssistantModule Class : ExportTaskAsync Method
A unique identifier used to identify the project task item to export. This identifier is the return value from the OpenTaskAsync(String) or OpenTaskAsync(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.
Exports the specified task item to an ArcGIS Pro .esriTasks file at the defined location.
Syntax
public static Task<string> ExportTaskAsync( 
   Guid taskItemGuid,
   string path
)
Public Shared Function ExportTaskAsync( _
   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 OpenTaskAsync(String) or OpenTaskAsync(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
// 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";
  string fileName = await TaskAssistantModule.ExportTaskAsync(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 10, Windows 8.1, Windows 7

See Also

Reference

TaskAssistantModule Class
TaskAssistantModule Members