D
David Lozzi
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.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))
Dim fileName As String = "WO-" & Request("woid") & ".pdf"
Dim fs As FileStream = File.Create("c:\temp\" & fileName,
strStream.BaseStream.Length)
Dim writer As New IO.BinaryWriter(fs)
writer.Write(strStream.ReadBytes(strStream.BaseStream.Length))
writer.Flush()
writer.Close()
fs.Dispose()
fs.Close()
strStream.Close()
crReport.Close()
and to delete I simply
File.Delete(filePath)
Thanks a million!
David Lozzi
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.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))
Dim fileName As String = "WO-" & Request("woid") & ".pdf"
Dim fs As FileStream = File.Create("c:\temp\" & fileName,
strStream.BaseStream.Length)
Dim writer As New IO.BinaryWriter(fs)
writer.Write(strStream.ReadBytes(strStream.BaseStream.Length))
writer.Flush()
writer.Close()
fs.Dispose()
fs.Close()
strStream.Close()
crReport.Close()
and to delete I simply
File.Delete(filePath)
Thanks a million!
David Lozzi