I am using the following code to print a file, this working fine but i am not sure that why this is printing with default printer, i want to use the printer specified in this line P.StartInfo.Arguments = "Hp 3500";

Please any one help me.

Here is my code...

System.Diagnostics.Process P = new Process();

string filename = "c:\doc.txt";
P.StartInfo.FileName = filename;
P.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;


P.StartInfo.Verb = "PrintTo";
P.StartInfo.Arguments = "Hp 3500";

P.StartInfo.CreateNoWindow = true;

P.Start();

Thanks in advance.

You can get the default printer name, the other way:

PrinterSettings ps = new PrinterSettings();
P.StartInfo.Arguments = ps.PrinterName;

Regards,

Nicola Losacco

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.