【发布时间】:2020-01-25 21:35:57
【问题描述】:
我想在没有用户交互的情况下从 C# 代码打印 PDF 文件。
我尝试了this accepted answer,但它不适合我。
这是我试过的代码:
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = @"G:\Visual Studio Projects\PrintWithoutGUI\PrintWithoutGUI\Courses.pdf" //put the correct path here
};
p.Start();
我得到了这个异常:
System.ComponentModel.Win32Exception: '指定的可执行文件不是此操作系统平台的有效应用程序。'`
【问题讨论】:
-
尝试将
UseShellExecute设置为true。