Open network printer as file in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

how do i open a network printer as a file in C#?

I can open the printer and write a line to it in vb6 just like this:

Open FindPrinter("\\ip123\thePrinter") For Output As #1
Print #1, "Hallo world!"
Close #1

the equivalent in C# as far as i can see does not seem to work:

IO.StreamWriter swMyPrinter;
swMyPrinter = new IO.StreamWriter("\\ip123\thePrinter");
swMyPrinter.WriteLine("Hallo\n");
swMyPrinter.Close();

this returns an error telling me i need to call 'CreateFile' myself and then
use 'FileStream' contructors if i want to open devices like this. I think
this type of thing may only allow me to open a local printer on LPT1.

Is there a simple way of opening a network printer for writing?
I am using a xerox printer and would like to be able to send 'VIPP' comands
to it easily once i have written a reusable class that will facilitate this.

Thanks in advance
yours sincerely
Edd
 
anyone any ideas?
I tried the CreateFile/FileStream approach but this does only seem to let me
print to a local printer.
Are there some sort of security settings that stop .net opening remote
fils/printers?

thanks again
Edd
 
Back
Top