How to check printer status in C #?
I have been printing in C # quite recently and am trying to find the current state of a particular printer (if disabled, if not present, etc.) before printing.
LocalPrintServer server = new LocalPrintServer();
PrintQueue printQueue = server.GetPrintQueue("EPSON WF-2540 Series");
MessageBox.Show(printQueue.IsOffline.ToString());
The code seems to find the specified printer successfully, but always sees it as online. It doesn't matter if the printer is on, off, or even off (I'm using a direct USB connection). Does anyone have any ideas as to what might be causing this? Thanks in advance for that I am very grateful!
+3
source to share
1 answer
From the MSDN documentation on the PrintQueue.IsOffline member (remarks section):
If the printer does not support a signal with this value, then the property is always false.
Apparently this is your case and this property is never set to True.
+7
source to share