代码:
Process printProcess = new Process();
printProcess.StartInfo.Verb = "Print";
printProcess.StartInfo.Arguments = printerName;
printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printProcess.StartInfo.CreateNoWindow = true;
printProcess.StartInfo.FileName = fileName;
printProcess.Start();
问题:
红底那行代码,不起作用。也可以说我不太清楚这个属性是做什么用的,我这里将打印机的名字赋给了Arguments,但是在打印前不论我选择那个打印机,都是使用默认的打印机去打印,请问有没有办法解决这个问题。
关注!
printProcess.StartInfo.Arguments = printerName;
应该指定打印机的物理位置(全路径),如果你指定一个名字,找不到打印机,就用默认的打印机了.
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc"; myProcess.StartInfo.Verb = "Print"; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start();