示例#1
0
        public static void ProtectDocument()
        {
            //Load an existing word file
            WordFile            wordFile = new WordFile();
            WordDocument        document = wordFile.Import(File.ReadAllBytes("Sample.docx"));
            WordDocumentBuilder builder  = new WordDocumentBuilder(document);

            //Protect file with password and permission
            builder.Protect("password", Protection.ProtectionMode.AllowComments);

            File.WriteAllBytes("Protected.docx", wordFile.Export(document));
        }