C# - Check if the printer is online

By , 9/15/2008
(1 ratings)
Check if the printer is online
using System.Drawing.Printing;

/// <summary>
/// Checks the printer.
/// </summary>
/// <param name="printerName">The printername.</param>
/// <returns></returns>
private bool CheckPrinter(string printerName)
{
    bool online = false;
    try
    {
        PrintDocument printDocument = new PrintDocument();
        printDocument.PrinterSettings.PrinterName = printerName;
        online = printDocument.PrinterSettings.IsValid;
    }
    catch
    {
        online = false;
    }
    return online;
}
Tagged with printer, online.

2 Comments

By Mason Bogert, 6/4/2012
Does not work. Always returns true.
By robertgtaylor1, 12/9/2015
Try this
http://www.codeproject.com/Articles/6069/How-to-Check-if-your-Printer-is-Connected-using-C
It worked for me
 

Log in, to comment!