c# word interop encrypt with password protect with password
public static void EncryptWithPassword(string unEncryptedWordPath, string password)
{
Word.Application wordApp = null;
Word.Document document = null; try
{
object missung = System.Type.Missing;
object odocPath = unEncryptedWordPath;
object opassword = password; wordApp = new Word.Application();
document = wordApp.Documents.Open(odocPath);
document.Password = password;
document.SaveAs(ref odocPath, Word.WdSaveFormat.wdFormatDocumentDefault);
}
catch (Exception e)
{
string s = e.ToString();
Console.WriteLine(s);
throw;
}
finally
{
Quit(wordApp, document);
}
} public static void Quit(Word._Application wordApp, Word._Document doc)
{
if(doc != null)
((Word._Document)doc).Close(Word.WdSaveOptions.wdDoNotSaveChanges);
object ofalse = false;
//ref false to prevent the Word Process Hang in Task Manager
if(wordApp !=null && wordApp.Application != null)
((Word._Application)wordApp.Application).Quit(ref ofalse, ref ofalse, ref ofalse);
}
c# word interop encrypt with password protect with password的更多相关文章
- MySQL加入服务、设置password、改动password
修正:加入MySQL服务时,能够不带版本.也就说以下的全部MySQL57能够直接写成MySQL!希望大家注意. MySQL安装好之后,往往还须要再做一些设置! 1.加入MySQL服务: 输入命令cmd ...
- Password Management:Hardcoded Password 密码管理:硬编码密码
- Fortify漏洞之Dynamic Code Evaluation: Code Injection(动态脚本注入)和 Password Management: Hardcoded Password(密码硬编码)
继续对Fortify的漏洞进行总结,本篇主要针对 Dynamic Code Evaluation: Code Injection(动态脚本注入) 和 Password Management: Har ...
- C# Protect the Password inside a TextBox ZZ
If the Text property is called, it will send an WM_GETTEXT message, so it will surely be an internal ...
- 密码硬编码(Password Management: Hardcoded Password)
在对项目进行安全扫描时,发现一些密码硬编码问题,本文主要三个方面:1)什么是密码硬编码:2)密码硬编码的危害:3)密码硬编码的解决方案. 一 什么是密码硬编码 将密码以明文的形式直接写到代码中,就是密 ...
- webshell 生成工具 b374k
还在为不会写webshell而感到心累?还在为webshell有后而不敢用?? b374k,我们首先去github下载b374k https://github.com/b374k/b374k.git ...
- 在C#中使用Spire.doc对word的操作总结
在C#中使用Spire.doc对word的操作总结 在最近的工程中我们要处理一些word文档.通过在网上的大量搜索,我发现大多数软件功能不是不完整就是有重复.极少数可以完全实现的word组件又要收费. ...
- C#操作Word文档(加密、解密、对应书签插入分页符)
原文:C#操作Word文档(加密.解密.对应书签插入分页符) 最近做一个项目,客户要求对已经生成好的RTF文件中的内容进行分页显示,由于之前对这方面没有什么了解,后来在网上也找了相关的资料,并结合自己 ...
- (转)C#操作Word文档
原文1地址:http://www.cnblogs.com/lantionzy/archive/2009/10/23/1588511.html 原文2地址: http://www.cnblogs.com ...
随机推荐
- IDEA Maven项目的Mybatis逆向工程
IDEA Maven项目的Mybatis逆向工程 1.配置.pom 如果是在多模块开发下,该文件逆向工程要生成的那个模块下的pom文件. <build> <plugins> & ...
- Docker Swarm集群中部署Traefik负载均衡器
一.创建单节点的Docker Swarm集群 docker swarm init 二.在Swarm集群中创建一个网络 docker network create --driver=overlay tr ...
- clientHeight、offsetHeight、scrollHeight、offsetTop、scrollTop
clientHeight:包括padding但不包括border.水平滚动条.margin的元素的高度.对于inline的元素这个属性一直是0,单位px,只读元素. offsetHeight:包括pa ...
- SQL Server 2008 无法安装U890
安装U890,环境检测的时候,却提示数据库不符合要求, 解决方法: 通过修改SQLServer的版本号 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServ ...
- Springboot使用alibaba的fastJson,@JSONField不起作用的问题
在Springboot中默认的JSON解析框架是jackson 今天引入alibaba的fastjson,使用@JSONField(serialize=false),让@RestController转 ...
- 20190321xlVBA_汇总表按模板生成明细表
Public Sub 汇总表转信息表() '日期 '作者 Next 'QQ 84857038 Dim Wb, Sht, msht, NewSht, rng Set Wb = Application.T ...
- 撸一个小型PHP框架
项目地址:https://packagist.org/packages/cshaptx4869/frame # 开发中... ## 20190410 注解路由 ## 20190411 依赖注入 容器I ...
- 记录下自己VUE项目用Hbuider打包后启动白屏问题
刚用VUE做项目,之前测试时vue创建的自身项目打包都是启动OK没问题.今天打包自己的时,启动一直白屏.折磨了好久,百度了一堆.终于找到了方法. 首先是在config/index.js里面 build ...
- 安装在类虚拟机crossover中的容器怎么进行的备份和恢复
备份教程: 步骤一:运行CrossOver,选中相关容器,然后在[容器]中找到并点击[导出“MathType6.9b_Trial_YY.exe”到存档],或者直接右击容器名称,然后选择[导出“Math ...
- weblogic安装部署ODM下jrules-res-xu-WL10.rar出现Can't find com.ibm.rules.res.xu.messages bundle异常
Windows: weblogic用户新建域文件夹里面,bin目录下找到setDomainEnv.cmd文件 在set JAVA_OPTIONS=%JAVA_OPTIONS% 后面添加: " ...