Posted By

rengber on 02/14/07


Tagged


Versions (?)

Check the Status of a Printer


 / Published in: C#
 

Amazingly fast. Doesn't throw exceptions if the printer doesn't exist.

  1. public bool IsValid
  2. {
  3. get
  4. {
  5. bool retVal = false;
  6. try
  7. {
  8. PrintDocument pd = new PrintDocument();
  9. pd.PrinterSettings.PrinterName = printerName;
  10. retVal = pd.PrinterSettings.IsValid;
  11. }
  12. catch(System.Exception ex)
  13. {
  14. string errorMsg = "";
  15. errorMsg = "Printer Error:" + printerName + ex.ToString();
  16. Trace.WriteLine(errorMsg);
  17. retVal = false;
  18. }
  19. return retVal;
  20. }
  21. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: joepajj on November 27, 2007

I'll try it, Thanks for advanced.

You need to login to post a comment.