Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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
C# 排除远程桌面连接重定向的打印机_C#_.net_Wpf_Printing_Remote Desktop - Fatal编程技术网

C# 排除远程桌面连接重定向的打印机

C# 排除远程桌面连接重定向的打印机,c#,.net,wpf,printing,remote-desktop,C#,.net,Wpf,Printing,Remote Desktop,我有一个使用LocalPrintServer类枚举所有本地安装的打印机的方法。当有人从远程桌面连接使用应用程序时,我想安装远程桌面连接重定向的打印机 using (LocalPrintServer printServer = new LocalPrintServer()) { var printQueuesOnLocalServer = printServer.GetPrintQueues( new[

我有一个使用LocalPrintServer类枚举所有本地安装的打印机的方法。当有人从远程桌面连接使用应用程序时,我想安装远程桌面连接重定向的打印机

 using (LocalPrintServer printServer = new LocalPrintServer())
            {
                var printQueuesOnLocalServer = printServer.GetPrintQueues(
                   new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });

                var terminalRedirectedPrintQueues = printQueuesOnLocalServer
                    .Except(printServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.TerminalServer }));

                // Filter out the printers that are redirected from a remote desktop connection
                // TODO: doesn't work, GetPrintQueues always returns all printers
                foreach (PrintQueue printer in printQueuesOnLocalServer.Where(
                    p => !terminalRedirectedPrintQueues.Select(t => t.FullName).Contains(p.FullName)))
                {
                    yield return printer.FullName;
                }
            }
不幸的是,返回的枚举始终为空,因为对GetPrintQueues的两个调用返回相同的打印机集合,尽管使用不同的参数调用。这是机器的问题吗?还是我只是误解了GetPrintQueues的工作方式