title: How to send multiple files to the printer with one Process call
body: <p>I need to print multiple PDF-files from the hard-drive. I have found this beautiful <a href="https://stackoverflow.com/questions/6103705/how-can-i-send-a-file-document-to-the-printer-and-have-it-print">solution</a> of how to send a file to the printer. The problem with this solution is that if you want to print multiple files you have to wait for each file for the process to finish.</p>
  
  <p>in the command shell it is possible to use the same command with multiple filenames:  <code>print /D:printerName file1.pdf file2.pdf</code>
  and one call would print them all.</p>
  
  <p>unfortunately simply just to put all the filenames into the <code>ProcessStartInfo</code> doesn't work</p>
  
  <pre><code>string filenames = @"file1.pdf file2.pdf file3.pdf"
  ProcessStartInfo info = new ProcessStartInfo();
  info.Verb = "print";
  info.FileName = filenames;
  </code></pre>
  
  <p>neither does it to put the filenames as <code>Arguments</code> of the <code>Process</code></p>
  
  <pre><code>info.Arguments = filename;
  </code></pre>
  
  <p>I always get the error: Cannot find the file!</p>
  
  <p>How can I print a multitude of files with one process call?</p>
  
  <p>Here is an example of how I use it now:</p>
  
  <pre><code>public void printWithPrinter(string filename, string printerName)
  {
  
      var procInfo = new ProcessStartInfo();    
      // the file name is a string of multiple filenames separated by space
      procInfo.FileName = filename;
      procInfo.Verb = "printto";
      procInfo.WindowStyle = ProcessWindowStyle.Hidden;
      procInfo.CreateNoWindow = true;
  
      // select the printer
      procInfo.Arguments = "\"" + printerName + "\""; 
      // doesn't work
      //procInfo.Arguments = "\"" + printerName + "\"" + " " + filename; 
  
      Process p = new Process();
      p.StartInfo = procInfo;
  
      p.Start();
  
      p.WaitForInputIdle();
      //Thread.Sleep(3000;)
      if (!p.CloseMainWindow()) p.Kill();
  }
  </code></pre>