.net';s process类不会将我的文件发送到打印机,但不会返回错误
我正在尝试使用.NET 4.0库中的Process和ProcessInfo类,按照Microsoft提供的以下说明,以编程方式打印文件 我已在\\server\printername设置了网络打印机,并且能够在该位置打印测试页 但是,当我在visual studio中运行此代码时,它不会打印,也不会返回任何表示存在问题的错误:.net';s process类不会将我的文件发送到打印机,但不会返回错误,.net,windows,.net,Windows,我正在尝试使用.NET 4.0库中的Process和ProcessInfo类,按照Microsoft提供的以下说明,以编程方式打印文件 我已在\\server\printername设置了网络打印机,并且能够在该位置打印测试页 但是,当我在visual studio中运行此代码时,它不会打印,也不会返回任何表示存在问题的错误: Dim proc As New Process Dim startInfo As New ProcessStartInfo(filename) p
Dim proc As New Process
Dim startInfo As New ProcessStartInfo(filename)
proc.StartInfo.FileName = filename
proc.StartInfo.Verb = "printto"
startInfo.Arguments = "\\server\printername"
proc.StartInfo = startInfo
proc.Start()
据我所知,所有这些代码所做的就是在一个新窗口中打开txt文件
如果尝试从CMD shell运行该进程,则会出现以下错误:
print /d:\\servername\printername C:\path\filename.txt
unable to initialize device \\servername\printername
我可以采取哪些步骤来消除此问题的bug?设置属性后,您将覆盖proc.StartInfo 尝试:
不用担心,我们都有这样的时刻
Dim proc As New Process
Dim startInfo As New ProcessStartInfo(filename)
startInfo.FileName = filename
startInfo.Verb = "printto"
startInfo.Arguments = "\\server\printername"
proc.StartInfo = startInfo
proc.Start()