473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Open network printer as file in C#

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

Aug 24 '06 #1
1 6020
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

"empika" wrote:
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
Aug 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Maileen | last post by:
Hi, I have 2 questions : 1. - I want to print from my ASP page directly to my network printer. For this i use the following code, but everytime, my document to print is sent to local and...
11
by: pamelafluente | last post by:
I am doing my own PrintDialog, and have placed there a combo with the printer names, as in the PrintDialog provided by VB.NET. Here is the question: how do I open the native windows printer...
56
by: peng | last post by:
Hi, I am development a project using C#.Net. Inside application, it needs to print labels on different Zebra label printers on the network. I used a shell script, but it only worked on the...
2
by: frank | last post by:
Hello, I am developing an vb.net app which needs the functionality to print a report to a specific printer on the network. Can't seem to find much information concerning this. How do I go about:...
0
by: empika | last post by:
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,...
1
by: Scott | last post by:
Hello- I have a contol button on a form that I want to code to open a report (rptReviews), then display the print dialogue box so that users can select a printer. This report needs color, but...
3
by: NewToNetworks | last post by:
Hi, hello, help! I am new to networking so please forgive me if this is a simple question. I have been at this for hours to no avail. I"m trying to network my Mac G5, running OSX 10.4.7 Tiger, a...
0
by: jigsmshah | last post by:
i am working on a project (windows service using VB.Net and C#) which gets the check details and check images from the database and prints the check to a printer. Printer name is configured in a...
1
by: ekynox | last post by:
Hi guys, have been playing with WMI to add a network printer connection to a Windows XP pc. My environment consists of a server running Windows Server 2003 and Visual Studio 2005 and a test pc...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.