ASPOSE.WORDS for .NET 1.1 - Adding Password protection to a .doc file

Hi,
I am writing an automated application (.NET 1.1 C#) that is used to remove the password from 1000’s of .doc files. The application also has a rollback feature, which means passwords have to reapplied to these files. I don’t seem to be able to set a password on my .doc files using the Protect() method. I receive no error/exceptions.
The code snippet is as follows:

string MyPassword = "PWD123456"
SaveOptions so = SaveOptions.CreateSaveOptions(docFileName);
_Doc.Protect(ProtectionType.NoProtection, MyPassword);
_Doc.Save(docFileName, so);

The only requirement is to add a password to my file and save. The document is saved but the password is not applied, I have no need to protect the document or parts of it, in any other way.
Can someone please advise :o)
ta
James

Hi

Thanks for your request. It seems, what you are talking about is document encryption (i.e. you cannot open document without entering a password). Aspose.Words at the moment cannot encrypt documents, it can only apply document protection and set password to modify.
https://docs.aspose.com/words/net/protect-or-encrypt-a-document/
https://reference.aspose.com/words/net/aspose.words/document/writeprotection/
Aspose.Words, however, supports loading encrypted documents.
Your request has been linked to the appropriate issue. You will be notified as soon as document encryption is supported.
Best regards.

Hi,

Just so I have my facts clear on this, it is not currently possible to password protect a document using Aspose, i.e. when the document is opened it asks the user to enter a password.
If so, it seems odd as I am able to remove a password (set it to empty.string) from a Word doc and re-save without it; which is surely the same as setting a password?
Kind Regards
James

Hi

Thank you for additional information. You can change protection password, but you cannot change “Password to Open” (these are different things). If you open encrypted document using Aspose.Words, you need to pass the password as a parameter into Document constructor.
After saving, the output document will not be encrypted, i.e. MS Word will not ask you to enter the password to open it.
Also, please attach your input document here.
Best regards,

Hi,
Many thanks I think that confirms things. It is the “Password To Open” that I wanted to change, however it seems that is not possible currently.
Currently I open encrypted documents using the password as you say, then use the Unprotect() method to remove the “Password To Open” before saving, but it seems from your reply that I don’t need to do that, in fact just saving the document will remove the “Password To Open”.
Many Thanks
James

Hi James,

Thank you for additional information. You are right; Unprotect method has no effect on document encryption.
We will let you know once encryption of documents is supported.
Best regards,

The issues you have found earlier (filed as WORDSNET-1724) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(7)