Aspose.Words password protection issue

Hello,

I have problems saving an existing docx file with a password, so that the file can only be opened if you enter the password. So far this code worked, now the output file is corrupt.

var doc = new Aspose.Words.Document("Unprotected.docx");
var docSaveOptions = new DocSaveOptions(SaveFormat.Doc)
{
    Password = "123"
};
doc.Save("Protected.docx", docSaveOptions);

I use the latest version.

Kind Regards,
Andy

I solved the problem :slight_smile:

Output Filename must be .doc, instead of .docx :slight_smile:

Can be closed, thanks :slight_smile:
Andy

@AStelzner It is perfect that you managed to solve the problem. Yes, you are right DocSaveOptions is for DOC format. If you need to save document as DOCX, you should use OoxmlSaveOptions:

Document doc = new Document("Unprotected.docx");
OoxmlSaveOptions docxSaveOptions = new OoxmlSaveOptions(SaveFormat.Doc)
{
    Password = "123"
};
doc.Save("Protected.docx", docxSaveOptions);