Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.rpt file in temp directory (Crystal report 9)

Status
Not open for further replies.

mir23

Programmer
Oct 28, 2003
11
BE
Hi All,

I have create a report which is exported to pdf with a typed dataset as datasource.
The code bellow is running well but it always generate a new .rpt file on the server.
I wonder how to delete that .rpt file in the temp dir.
Does anyone have an idea?

Thanks,

Here is my VB code:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
reportDocument1 = New CrystalReport3()

Dim ds As New dsAdhesionClub()
Dim dr As dsAdhesionClub.ClubRow = ds.Club.NewClubRow
dr.clubName = "Club Name"
dr.firstName = "First Name"
dr.lastName = "Last Name"
dr._function = "Web Dev"
dr.eMail = "Email"
dr.gender = "Male"
ds.Club.Rows.Add(dr)

ShowReport(reportDocument1, ds)
End Sub


Public Sub ShowReport(ByVal r As ReportClass, ByVal ds As DataSet)
r.SetDataSource(ds)

Dim objRep As TextObject = r.ReportDefinition.ReportObjects.Item("Text7")
objRep.Text = "Club Name"
objRep.ObjectFormat.CssClass = ""


'Sets the file name for the PDF
Dim diskDestin As New DiskFileDestinationOptions()
Dim path As String = "C:\myPdf" & Session.SessionID.ToString & ".pdf"
diskDestin.DiskFileName = path

'Sets export options, including format of file to PDF

Dim expOption As ExportOptions = r.ExportOptions
With expOption
.DestinationOptions = diskDestin
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With

With r
.FormatEngine.PrintOptions.PaperSize = PaperSize.PaperA4
.FormatEngine.PrintOptions.PaperOrientation = PaperOrientation.Portrait
.Export()
.Close()
End With
r = Nothing
End Sub
 
I think this is the cleanest solution to delete the temporary file generate by the reportDocument Class without waiting for the garbage collection:

Call the Dispose() Methode

This should help in similar situations.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top