title: pdf document being used by another process
body: <p>I have two PDF files: <code>Pdf A</code> and <code>Pdf B</code>. <code>Pdf A</code> already exists on the computer's <code>C:</code> drive and <code>Pdf B</code> gets generated through the program which also lands in the <code>C:</code> drive.</p>
  
  <p>What I want to do is combine the two so that the <code>Pdf A</code>'s pages show first and then <code>Pdf B</code>'s pages show after that.</p>
  
  <p>Here is my code that tries to combine the two given a list of PDFs (<code>Pdf A</code> is the first element and <code>Pdf B</code> is the second element in the <code>files</code> list, and the <code>destinationfile</code> is <code>Pdf A</code>):</p>
  
  <pre><code>public static void MergePdfFiles(string destinationfile, List&lt;string&gt; files)
  {
      Document document = null;
  
      try
      {
          List&lt;PdfReader&gt; readers = new List&lt;PdfReader&gt;();
          List&lt;int&gt; pages = new List&lt;int&gt;();
  
          foreach (string file in files)
          {
              readers.Add(new PdfReader(file));
          }
  
          document = new Document(readers[0].GetPageSizeWithRotation(1));
  
          PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(destinationfile, FileMode.Create));
  
          document.Open();
  
          foreach (PdfReader reader in readers)
          {
              pages.Add(reader.NumberOfPages);
              WritePage(reader, document, writer);
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.ToString());
      }
      finally
      {
          //being used by another process
          document.Close();
      }
  }
  </code></pre>
  
  <p>The issue appears when the document object tries to close.  It says it is being used another process.</p>
  
  <p>What 'other' process is using it?</p>