水晶报表问题...........
文件 h:\inetpub\wwwroot\JieXiuWebDMIS8\Test\CrystalReport1.rpt 内出错:拒绝访问报表文件。其他程序可能正在使用它。
原来都没问题,前天就是这样了。why?
程序是这样的:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Public Class WebForm3
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Dim oRpt As New ReportDocument
Dim RCSoft As New ReportClass
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
myForm_Print()
Else
End If
End Sub
Sub myForm_Print()
oRpt.Load(Server.MapPath("CrystalReport1.rpt"))
Dim FilePath As String = "www.pdf"
Dim strFileName As String = Server.MapPath(FilePath)
'RCSoft.ExportToDisk(strFileName, oRpt, 1)
Dim op As New ExportOptions
Dim disk As New DiskFileDestinationOptions
Dim sDate As String
disk.DiskFileName = Server.MapPath("www.pdf") '保存临时路径,自己可以修改
op = oRpt.ExportOptions
op.ExportFormatType = ExportFormatType.PortableDocFormat
op.ExportDestinationType = ExportDestinationType.DiskFile
op.DestinationOptions = disk
oRpt.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
'Response.ContentType = "application/octet-stream"
Response.WriteFile(disk.DiskFileName)
Response.Flush()
Response.Close()
'System.IO.File.Delete(disk.DiskFileName)
Response.Redirect("www.pdf")
End Sub
End Class
问题点数:200、回复次数:5Top
1 楼cancersyf(fengzhimei)回复于 2004-11-03 00:42:46 得分 0
Ensure the filename is correct and the ASPNET account has
permissions to open the file. You can try using the FileStream class to
open the RPT file.Top
2 楼saucer(思归)回复于 2004-11-03 05:46:25 得分 150
出错消息不太正确,你的问题在于这行
disk.DiskFileName = Server.MapPath("www.pdf")
这是输出,你需要给ASPNET账号(或者Network Service账号,如果你用Windows 2003的话)在当前目录写或修改的权限
参考
http://dotnetjunkies.com/WebLog/richard.dudley/archive/2004/05/24/14362.aspxTop
3 楼cansum396(漆黑的夜)回复于 2004-11-03 07:09:20 得分 0
楼上厉害!Top
4 楼seztty(01)回复于 2004-11-03 08:16:00 得分 0
permissoin is not correctTop
5 楼goody9807(http://goody9807.cnblogs.com)回复于 2004-11-03 08:51:52 得分 50
http://blog.csdn.net/goody9807/articles/138822.aspxTop




