C# 調用打印機打印文件,一般狀況下,例如Word、Excel、PDF等可使用一些對應的組件進行打印,另一個通用的方式是直接啓用一個打印的進程進行打印。示例代碼以下:spa
using System.Diagnostics; string filePath = "文件路徑"; string printer = "打印機"; ProcessStartInfo info = new ProcessStartInfo(); info.Arguments = "\"" + printer + "\""; info.Verb = "PrintTo"; info.FileName = filePath; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process p = new Process(); p.StartInfo = info; p.Start(); p.WaitForInputIdle();