|
// For more examples, please visit https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet |
|
|
|
// Get client credentials from https://dashboard.aspose.cloud/ |
|
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14"; |
|
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2"; |
|
|
|
// create TasksApi instance |
|
TasksApi tasksApi = new TasksApi(clientSecret, clientID); |
|
|
|
// Name of input MPP file |
|
String inputFile = "Home move plan.mpp"; |
|
// name of resultant HTML file |
|
String resultant = "resultant.html"; |
|
|
|
// create MPP file conversion request |
|
var request = new GetTaskDocumentWithFormatRequest(); |
|
|
|
// specify the input MPP name from cloud storage |
|
request.Name = inputFile; |
|
|
|
// set HTML as resultant format |
|
request.Format = ProjectFileFormat.Html; |
|
|
|
// If this 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 MPP to HTML conversion and return output in stream instance |
|
Stream response = tasksApi.GetTaskDocumentWithFormat(request); |
|
|
|
if (response != null) |
|
{ |
|
Console.WriteLine("MS Project file (MPP) successfully converted to HTML !"); |
|
} |
|
|
|
// custom method to save resultant file on local system drive |
|
saveToDisk(response, resultant); |
|
|
|
// Method to save stream content to file on local drive |
|
public static void saveToDisk(Stream responseStream, String resultantFile) |
|
{ |
|
var fileStream = File.Create(resultantFile); |
|
responseStream.Seek(0, SeekOrigin.Begin); |
|
responseStream.CopyTo(fileStream); |
|
fileStream.Close(); |
|
} |