C# 打印文件

using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;

System.Diagnostics.Process print = new System.Diagnostics.Process();//不现实调用程序窗口,但是对于某些应用无效
print.StartInfo.CreateNoWindow = true;
print.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//采用操作系统自动识别的模式
print.StartInfo.UseShellExecute = true;//要打印的文件路径,可以是WORD,EXCEL,PDF,TXT等等
print.StartInfo.FileName = @"e:\a.xls";//指定执行的动作,是打印,即print,打开是 open
print.StartInfo.Verb = "print";//开始
print.Start();

猜你喜欢

转载自blog.csdn.net/lvxingzhe3/article/details/121887046