Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net';s process类不会将我的文件发送到打印机,但不会返回错误_.net_Windows - Fatal编程技术网

.net';s process类不会将我的文件发送到打印机,但不会返回错误

.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

我正在尝试使用.NET 4.0库中的Process和ProcessInfo类,按照Microsoft提供的以下说明,以编程方式打印文件

我已在\\server\printername设置了网络打印机,并且能够在该位置打印测试页

但是,当我在visual studio中运行此代码时,它不会打印,也不会返回任何表示存在问题的错误:

    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()