To check if a printer exists in C# and VB.NET you can use the following snippet.
Sample C#
public static bool PrinterExists(string printerName) { if (String.IsNullOrEmpty(printerName)) { throw new ArgumentNullException("printerName");} return PrinterSettings.InstalledPrinters.Cast<string>().Any(name => printerName.ToUpper().Trim() == name.ToUpper().Trim()); }
Sample VB.NET
Public Shared Function PrinterExists(printerName As String) As Boolean If String.IsNullOrEmpty(printerName) Then Throw New ArgumentNullException("printerName") End If Return PrinterSettings.InstalledPrinters.Cast(Of String)().Any(Function(name) printerName.ToUpper().Trim() = name.ToUpper().Trim()) End Function
RT @CodeSnippetsNET: Check if a printer exists in C# and #VB .NET http://t.co/bkp8cF9BPo #csharp #dotnet #programming #code #coding #dev #d…
RT @CodeSnippetsNET: Check if a printer exists in C# and #VB .NET http://t.co/bkp8cF9BPo #csharp #dotnet #programming #code #coding #dev #d…