You need to escape the \ in your filename string. Either
p.StartInfo.FileName = @"G:\tst.prn";
or
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)
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.
Barcode, Labeling, Printing & Imaging tools for ASP.NET Developers
Marked as answer by Angie xu - MSFT on Mar 04, 2013 12:30 AM
vetrivelan R...
Member
82 Points
42 Posts
How to print the .PRN file using C#
Feb 23, 2013 02:25 AM|LINK
Hi All,
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";
p.Start();
And I tried Copy \B My.prnfilepath prn in command prombt, but both are not help
Please help me
Paul Linton
Star
13431 Points
2535 Posts
Re: How to print the .PRN file using C#
Feb 23, 2013 05:00 AM|LINK
You need to escape the \ in your filename string. Either
p.StartInfo.FileName = @"G:\tst.prn";
or
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)
Neodynamic
Participant
1008 Points
289 Posts
Re: How to print the .PRN file using C#
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.
Angie xu - M...
All-Star
18664 Points
1590 Posts
Microsoft
Re: How to print the .PRN file using C#
Feb 28, 2013 10:07 AM|LINK
Hi vetrivelan
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,
With regards
Feedback to us
Develop and promote your apps in Windows Store
smirnov
All-Star
23700 Points
4056 Posts
Re: How to print the .PRN file using C#
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.