This gist explains the steps and code snippet on how to convert MPP to XML format using Aspose.Tasks Cloud SDK for .NET.
For more information, please visit
This gist explains the steps and code snippet on how to convert MPP to XML format using Aspose.Tasks Cloud SDK for .NET.
For more information, please visit
This Gist contains code snippets related to the conversion of MPP files to XML format using Aspose.Tasks Cloud SDK for .NET |
// Get ClientID from https://dashboard.aspose.cloud/ | |
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44"; | |
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553"; | |
// create TasksApi instance | |
TasksApi tasksApi = new TasksApi(clientSecret, clientID); | |
// input MPP file name | |
String inputFile = "Home move plan.mpp"; | |
// resultant XML file name | |
String resultant = "Converted.xml"; | |
try | |
{ | |
// read the project document from local system into stream instance | |
using (var inputStream = new FileStream("C:\\Users\\shahbnay\\Downloads\\"+inputFile, FileMode.Open)) | |
{ | |
var uploadFileRequest = new PostCreateRequest("Home move plan.mpp", inputStream); | |
// upload file to cloud storage | |
tasksApi.UploadFile(uploadFileRequest); | |
} | |
// create MPP file conversion request | |
var request = new GetTaskDocumentWithFormatRequest(); | |
// specify the input MPP name from cloud storage | |
request.Name = inputFile; | |
// set XML as resultant format | |
request.Format = Aspose.Tasks.Cloud.Sdk.Model.ProjectFileFormat.Xml; | |
// If parameter is true, HTML resources are included as separate files and | |
// returned along with the resulting html file as a zip package. | |
request.ReturnAsZipArchive = false; | |
// perform document conversion operation | |
Stream response = tasksApi.GetTaskDocumentWithFormat(request); | |
if (response != null) | |
{ | |
Console.WriteLine("Successfully converted MPP to XML !"); | |
} | |
// custom method to save resultant file on local system drive | |
saveToDisk(response, "C:\\Users\\shahbnay\\Downloads\\" + resultant); | |
}catch (Exception ex) | |
{ | |
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} | |
// method to save stream content as file object | |
static void saveToDisk(Stream responseStream, String resultantFile) | |
{ | |
var fileStream = File.Create(resultantFile); | |
responseStream.Seek(0, SeekOrigin.Begin); | |
responseStream.CopyTo(fileStream); | |
fileStream.Close(); | |
} |