Click here to Skip to main content
15,887,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a sample application of print any file but it does not work for excel and .doc in selected printer on Xp and Vista.

The following is a sample code:
C#
Process p = new Process();
          
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
     ProcessStartInfo info = new ProcessStartInfo();
     info.FileName = sFilePath;
     info.CreateNoWindow = true;
     info.UseShellExecute = true;

     //info.Arguments = this.printDialog1.PrinterSettings.PrinterName;
                    
     info.Arguments = "\"\\\\" + Dns.GetHostName() + "\\" + printDialog1.PrinterSettings.PrinterName + "\"";

     info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                       
     p.StartInfo = info;
     bool sdfvgfs=   p.Start();
     p.Close();
}

Please anybody know about solution?
Thank You!
Posted
Updated 23-Mar-11 21:00pm
v2
Comments
Sandeep Mewara 23-Mar-11 6:30am    
Do you get any error? What?
kailas_khule 24-Mar-11 2:53am    
Thanks for reply.
Not any error but Procees is started at the same time cursor is blink some time and nothing happen after that.
Sandeep Mewara 24-Mar-11 3:00am    
Are you sure that the printer path is correctly formed? Checked that?
kailas_khule 24-Mar-11 3:09am    
Do you mean about info.filename or info.Argument.
1)info.filename is correct.
2)info.Argument is also correct is taken from (printDialog1.PrinterSettings.PrinterName) object
but I have also not sure about whcich parameter pass for info.Argument.
kailas_khule 24-Mar-11 7:03am    
info.FileName=sfilepath
here sfilepath is path of any file.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900