Howdy,
I am using ASP.Net 2.0 and Crystal Reports in VS 2005. I am taking a report,
converting it to PDF then writing it out to a folder. Then I attach this
file to an email and send it off. Once it's sent, I then want to delete the
file from the folder, and here lies the issue. When i try to delete it I get
an error stating the file is being used by another process.
Here's the code to create the file
Dim strStream As New
System.IO.Binar yReader(crRepor t.ExportToStrea m(CrystalDecisi ons.[Shared].ExportFormatTy pe.PortableDocF ormat))
Dim fileName As String = "WO-" & Request("woid") & ".pdf"
Dim fs As FileStream = File.Create("c: \temp\" & fileName,
strStream.BaseS tream.Length)
Dim writer As New IO.BinaryWriter (fs)
writer.Write(st rStream.ReadByt es(strStream.Ba seStream.Length ))
writer.Flush()
writer.Close()
fs.Dispose()
fs.Close()
strStream.Close ()
crReport.Close( )
and to delete I simply
File.Delete(fil ePath)
Thanks a million!
David Lozzi