创建打印服务器时,所有打印机名称均无效

时间:2019-03-22 16:35:23

标签: c# printing

我正在尝试使用以下代码创建PrintServer

    PrintServer printServer = new PrintServer(@"\\PrinterName");
    PrintQueueCollection printQueues = printServer.GetPrintQueues();

    foreach(PrintQueue pq in printQueues)
    {
        Console.WriteLine(pq.Name);
    }

但是似乎我输入的内容都会引发以下异常:

  

System.Printing.PrintServerException:'   创建PrintServer对象。 Win32错误:打印机名称为   无效。'

可能是我每次都输入了错误的打印机名称,但是尝试了几种可能的路径组合后,我可能会想到几种不同的打印机,并且每次用完时都会遇到相同的问题为此。

我尝试按照advice shown in this question启用“打印和文档”服务,但仍无济于事。

0 个答案:

没有答案