Author: nakins | Posted on: 4/7/2010 1:14:16 PM | Views : 320

I have an aspx form that take input data and fills in a pdf, then email the filled pdf to a certian person.  I'm using iTextSharp to do the pdf work. It all works fine, except when I try to delete the file that was created.  When I try to delete the file, I get an error saying that the file is being used by another process, which is the email part of the code. If I comment the email code out, it works.
What do I need to do get this to work? I'm don't know if I'm not closing something to stop a process, or if I'm going about this all wrong.  Please help.
Public Sub fill_form(ByVal Source As Object, ByVal e As EventArgs)
Dim newFile As String = "D:\Inetpub\wwwroot\dir\" + Name.Text + ".pdf"

Dim path As String = Request.MapPath("Form.pdf")
If File.Exists(path) Then
Dim r As New PdfReader(path)
...

Go to the complete details ...