title: Error when using iText: The process cannot access the file because it is being used by another process
body: <p>This error comes when I do not close the previously opened PDF file and create a new PDF again. I want to open the second file without closing the first file.</p>
  
  <blockquote>
    <p>The process cannot access the file 'C:\Users\Abc\Desktop\Slip.pdf' because it is being used by another process.</p>
  </blockquote>
  
  <pre><code>try
  {
      Document pdfDoc = new Document(new iTextSharp.text.Rectangle(190f, 240f), 0f, 0f, 0f, 0f);
  
      PdfWriter pdfwriter = PdfWriter.GetInstance(pdfDoc, new FileStream(
      Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Slip.pdf", FileMode.Create));
      pdfDoc.Open();
  
      PdfPTable table1 = new PdfPTable(2);
      table1.DefaultCell.Border = 0;
      table1.SetWidths(new int[] { 1, 6 });
  
      string imagepath = Server.MapPath("Images");
      iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(imagepath + "/sliplogo.png");
      image.ScalePercent(24f);
      table1.AddCell(image);
  
      //   Text.Alignment = Element.ALIGN_CENTER;
      Text1.Alignment = Element.ALIGN_CENTER;
      Text.Alignment = Element.ALIGN_CENTER;
      table1.AddCell(Text1);
      table1.AddCell("");
      table1.AddCell(Text);
      //  table1.AddCell(phrase);
  
      PdfPTable orderInfoTable5 = new PdfPTable(1);
      orderInfoTable5.DefaultCell.Border = 0;
      orderInfoTable5.AddCell("-------------------------------------");
  
      string tme = DateTime.Now.ToString("h:mm:ss tt");
      Paragraph Text2 = new Paragraph(tme, new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL));
  
      Paragraph Text3 = new Paragraph(DateAssign, new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL));
  
      pdfDoc.Add(table1);
      Text2.Alignment = Element.ALIGN_RIGHT;
      pdfDoc.Add(Text2);
  
      Text3.Alignment = Element.ALIGN_RIGHT;
      pdfDoc.Add(orderInfoTable5);
  
      pdfDoc.Close();
      System.Diagnostics.Process.Start(Environment.GetFolderPath(
      Environment.SpecialFolder.Desktop) + "/Slip.pdf");
  }
  catch (Exception ex)
  {
      Response.Write(ex.Message);
  }
  </code></pre>