1

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.

Stephan Bauer
  • 9,120
  • 5
  • 36
  • 58
Spades
  • 73
  • 2
  • 9
  • http://stackoverflow.com/questions/18704839/send-text-file-directly-to-network-printer – csenga Nov 25 '15 at 19:22
  • When I reference it by name it says: "The network name cannot be found. Yet it populates the combo box printer list without issue. *IF* I use "\\ServerName\prt0001" it works. But I need to reference it by the name the OS provides. – Spades Nov 25 '15 at 19:32

1 Answers1

1

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);
Anand
  • 116
  • 1
  • 6