Hi,
I have a code for exporting a crystal report.Net into PDF format. Code is as given below. I have two problems
1) For dialogue box which open on the client browser, if user clicks the OPEN button then the same window appears again and after
clicking one more time it shows the report in PDF format. So why its asking me the same window twice for OPEN button option?
2) For SAVE button option I want to delete the file from web server's C:/temp path after the user has downloaded the file. So how to
do it after completion of the response?
Code->
Public Function ExportReport(ByVal orpt As Object, ByVal FName As String)
Dim fileName As String
Dim path As String
Dim i As Int16
Dim ExportPath As String = "C:/Temp/"
crConnInfo.Password = "pompeii"
tInfo.ConnectionInfo = crConnInfo
orpt.Database.Tables(0).ApplyLogOnInfo(tInfo)
With orpt
.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
fileName = ExportPath & FName & ".pdf"
If fso.File.Exists(fileName) Then
fso.File.Delete(fileName)
End If
.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
dfdoStatement.DiskFileName = fileName
.ExportOptions.DestinationOptions = dfdoStatement
.Export()
End With
fileName = FName & ".pdf"
If fileName <> "" Then
path = ExportPath & fileName
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path)
If file.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()
Else
Response.Write("This file does not exist.")
End If
Else : Response.Write("Please provide a file to download.")
End If
End FunctionGo Bonkers over cricket with Balram D Maity