In my code, I've created a pdf file using itextsharp.
Somewhere in my code, I'm opening something and not closing it properly. I'm trying to delete the pdf after creating, but I keep getting an error that it's in use by a process. Any help appreciated. Dim FormFile As String = "form.pdf" Dim outFile As String = "Out.pdf" Dim reader As New PdfReader(FormFile) Dim Fstream As FileStream = New FileStream(outFile, FileMode.Create) Dim stamper As New PdfStamper(reader, Fstream)Dim pdfFormFields As AcroFields = stamper.AcroFields pdfFormFields.SetField("contractno", contractno.Text) blah blah blah Try Dim SendFrom As MailAddress = New MailAddress("someaddress@") Dim sendTo As MailAddress = New MailAddress("Someaddress@") Dim MyMessage As MailMessage = New MailMessage(SendFrom, sendTo) MyMessage.Subject = "Attached PDF " Dim attachFile As New Attachment("Out.pdf") MyMessage.Attachments.Add(attachFile) Dim mailClient As SmtpClient = New SmtpClient MyMessage.IsBodyHtml = False mailClient.Host = "mail.com" mailClient.Port = "25" mailClient.Credentials = New Net.NetworkCredential("fromaddress", "Password") mailClient.Send(MyMessage) Dim fileinfo As FileInfo = New FileInfo("Out.pdf") If fileinfo.Exists Then File.Delete("E:\0\1\61\159\1713648\user\1849424\htdocs\RRSolutions\Out1.pdf") End If Always results in System.IO.IOException: The process cannot access the file 'Out.pdf' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.Delete(String path) at RRSolutions_HighLimitsTest.Button1_Click(Object sender, EventArgs e) in Test.aspx.vb:line 102 Thanks in advance. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/