I have a problem choosing a printer to print my document.
My code is:
var filename = @"C:\Users\I\Desktop\test.doc"; PrintDialog pd = new PrintDialog(); pd.PrinterSettings =new PrinterSettings(); if (DialogResult.OK == pd.ShowDialog(this)) { Process objP = new Process(); objP.StartInfo.FileName = filename; objP.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //Hide the window. objP.StartInfo.Verb ="print"; objP.StartInfo.Arguments ="/p /h \"" + filename + "\" \"" + pd.PrinterSettings.PrinterName + "\""; objP.StartInfo.CreateNoWindow = false; //true;//!! Don't create a Window. objP.Start(); //!! Start the process !!// objP.CloseMainWindow(); }
and no matter what I choose, process
will always use the default printer, no matter what the value of pd.PrinterSettings.PrinterName
.
What is wrong with my code?
source share