Spades
Spades

Reputation: 73

Using File.Copy to send PDF to Printer by Printer Name

I am trying to send an PDF file to a printer using the File.Copy method in C#. When I reference the printer by name however, it always responds with

'Could not find a part of the path'

The printer name is fully qualified. The user is selecting from a combo box that displays all the systems printers using the PrinterSettings.InstalledPrinters values.

Am I missing something simple?

Example:

File.Copy(FileInfo.FullName, "\\\\ServerName\\PrinterName", true);

The "\\\\ServerName\\PrinterName" is directly one of the names from PrinterSettings.InstalledPrinters collection.

Upvotes: 1

Views: 5009

Answers (1)

Anand
Anand

Reputation: 126

Use one of the printer names that comes out of the printer classes.

foreach (String printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
     textBox1.Text += printer.ToString() + System.Environment.NewLine;
 }

See all the printers that are listed in this text box, copy and paste the printer name in the file.copy method.

File.Copy(FileInfo.FullName, **Printer name here**, true);

Upvotes: 1

Related Questions