Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Open network printer as file in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
empika - 24 Aug 2006 14:49 GMT
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
empika - 25 Aug 2006 11:05 GMT
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

> Hi
>
[quoted text clipped - 24 lines]
> yours sincerely
> Edd

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.