c# 本地查看文档(word、xls、pdf,甚至于exe)

打开帮助文档

System.Diagnostics.Process.Start(Directory.GetCurrentDirectory() + "\\" + "help.chm");

打开计算机

System.Diagnostics.Process.Start("C:\\windows\\system32\\" + "calc.pdf");

亲测可行。

转载于:https://www.cnblogs.com/huanjun/p/7975792.html

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用NPOI库中的WordToPdfConverter类将Word文档转换为PDF格式。以下是一个简单的示例代码: ```csharp using NPOI.XWPF.UserModel; using NPOI.XWPF.UserModel.Extensions; using NPOI.OpenXmlFormats.Wordprocessing; using NPOI.Util; using System.IO; // 读取Word文档 XWPFDocument doc = new XWPFDocument(File.OpenRead("doc.docx")); // 创建PDF输出流 FileStream pdfStream = new FileStream("doc.pdf", FileMode.Create); // 将Word文档转换为PDF格式 doc.EnsureMinimumCompatibility(XWPFDocument.MINIMUM_COMPATIBILITY); doc.GetPackage().SetPartContentType("/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"); doc.GetPackage().SetPartContentType("/word/styles.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"); doc.GetPackage().SetPartContentType("/word/fontTable.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"); doc.GetPackage().SetPartContentType("/word/settings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"); doc.GetPackage().SetPartContentType("/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"); doc.GetPackage().SetPartContentType("/word/theme/theme1.xml", "application/vnd.openxmlformats-officedocument.theme+xml"); doc.GetPackage().SetPartContentType("/docProps/core.xml", "application/vnd.openxmlformats-package.core-properties+xml"); doc.GetPackage().SetPartContentType("/docProps/app.xml", "application/vnd.openxmlformats-officedocument.extended-properties+xml"); doc.GetPackage().SetPartContentType("/word/_rels/document.xml.rels", "application/vnd.openxmlformats-package.relationships+xml"); doc.Write(pdfStream); // 关闭流 pdfStream.Close(); doc.Close(); ``` 在代码中,我们首先读取要转换的Word文档,然后创建一个PDF输出流,最后使用WordToPdfConverter类将文档转换为PDF格式并写入输出流。请注意,此代码示例仅适用于使用NPOI创建的Word文档。如果您需要转换其他格式的Word文档,可能需要使用其他库或工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值