Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 28, 2013 10:17 AM by smirnov
Feb 23, 2013 02:25 AM|LINK
I need to print the .prn file.
I tryed the following code it is not working
Process p = new Process();
p.StartInfo.FileName = "G:\tst.prn";
p.StartInfo.UseShellExecute = true;
p.StartInfo.Verb = "print";
And I tried Copy \B My.prnfilepath prn in command prombt, but both are not help
Please help me
Feb 23, 2013 05:00 AM|LINK
You need to escape the \ in your filename string. Either
p.StartInfo.FileName = @"G:\tst.prn";
p.StartInfo.FileName = "G:\\tst.prn";
If you still have a problem you could add an exit handler and check the ExitCode when it is called
p.Exited += new EventHandler(myProcess_exited);
In the handler check myProcess.ExitCode to get a start on what is happening.
(Of course, the obvious questions apply - does G:\tst.prn exist and is it accessible by the web server process, is there a default printer on this server)
Feb 23, 2013 12:06 PM|LINK
You're telling the Windows Shell to "print" a prn file. Are you sure you have a "print" command of the shell associated to PRN files? If you don't, then nothing will happen there.
You also said that tried COPY command.... is there any printer installed in your server? Not sure if you realize that your code will try to print to a printer installed on the server where your asp.net website is hosted in.
Feb 28, 2013 10:07 AM|LINK
You could refer the discussion about printing *.prn files using C#.net in MSDN forum(http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/fe100d00-48e2-4ca1-97b7-86fb95fa63bc),
hope it helps you,
Feb 28, 2013 10:17 AM|LINK
As it is mentioned by Neodynamic, try using COPY
copy /b filename.prn lpt1
Also, take a look at this example, I think it might help.