Free Support Forum - aspose.com

Delete generated file after execute template is over

Once mail merge template has been executed output file would be stored. Then I’ve to download it using the file name I got from JSON response. But the file stays in the storage and to conserve space it should be deleted is it correct? .NET SDK cannot do it, it just do GET but not delete?

Hi Denis,

Yes, you are right. You can use DeleteFile method of the Folder class to delete a file from storage as you can see at http://saaspose.com/docs/display/rest/Delete+a+Particular+File+from+Saaspose+%28.NET+SDK%29

You can pass name of the file if file in the root folder or you can pass complete path e.g. 'Folder1/File1.docx' if file is in a specific folder.

Best Regards,
Muhammad Ijaz
Support Developer, Saaspose Sialkot Team
http://www.saaspose.com

Thanks Muhammad!

The problem is - ExecuteMailMerge does not return the name of a temporary file created. So I've no way of knowing the actual file name to delete.

Best
Denis

Hi Denis,

Thanks a lot for you feedback. We will update these methods and support a new boolean parameter to let the users choose if they want to remove these files from storage, and let you know once it is done. In the meantime, you can call DeleteFile method in the ExecuteMailMerge method to delete downloaded files from Saaspose storage.

Best Regards,
Muhammad Ijaz
Support Developer, Saaspose Sialkot Team
http://www.saaspose.com

Hi Denis,

Now you can pass bool value to all the methods of MailMerge class; please download the latest version of .NET SDK from https://github.com/saaspose/Saaspose.SDK-for-.NET and use the following code for this purpose:

mailMerge.ExecuteMailMerege(fileName, xml, SaveFormat.Docx, "c:\\SimpleOut.docx", "folder1", true);

Best Regards,
Muhammad Ijaz
Support Developer, Saaspose Sialkot Team
http://www.saaspose.com