Hi David,
PS. Also it's a good way to use "using statement" for disposable objects
to be sure that object will be freed.
Using cn As Dim fs As FileStream = File.Create
// do something
End Using
Regards, Alex Meleta
[TechBlog]
http://devkids.blogspot.com
DL> Howdy,
DL>
DL> I am using ASP.Net 2.0 and Crystal Reports in VS 2005. I am taking a
DL> report, converting it to PDF then writing it out to a folder. Then I
DL> attach this file to an email and send it off. Once it's sent, I then
DL> want to delete the file from the folder, and here lies the issue.
DL> When i try to delete it I get an error stating the file is being
DL> used by another process.
DL>
DL> Here's the code to create the file
DL>
DL> Dim strStream As New
DL> System.IO.BinaryReader(crReport.ExportToStream(Cry stalDecisions.[Sha
DL> red].ExportFormatType.PortableDocFormat))
DL>
DL> Dim fileName As String = "WO-" & Request("woid") &
DL> ".pdf"
DL> Dim fs As FileStream = File.Create("c:\temp\" &
DL> fileName,
DL> strStream.BaseStream.Length)
DL> Dim writer As New IO.BinaryWriter(fs)
DL>
DL> writer.Write(strStream.ReadBytes(strStream.BaseStr eam.Length))
DL> writer.Flush()
DL> writer.Close()
DL> fs.Dispose()
DL> fs.Close()
DL> strStream.Close()
DL> crReport.Close()
DL> and to delete I simply
DL>
DL> File.Delete(filePath)
DL>
DL> Thanks a million!
DL> David Lozz