How to get all network printers in asp.net 4.0
Please any one help me to get all network printers. I get all printers installed in the local machine using "System.Drawing.Printing.PrinterSettings.InstalledPrinters".
But I can't get the printers which are in the Network. I try with "ManagementObjectSearcher" but I can't access this class. I think it does not support in framework 4.0.
开发者_运维问答I'm using ASP.NET 4.0, C#. Any help will be greatly appreciated.
Thanks Singaravelu.R.
if you cannot find/reference the ManagementObjectSearcher Class probably is because you did not add the proper reference to: System.Management.dll to your C# project. Surely it is supported also by .NET 4.
as you can see in this question: ManagementObjectSearcher select network printers? you can find all network printers in this way:
var searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Printer");
var results = searcher.Get();
IList<ManagementBaseObject> printers = new List<ManagementBaseObject>();
foreach (var printer in results) {
if ((bool)printer["Network"]) {
printers.Add(printer);
}
}
精彩评论