【问题标题】:Export to PDF (XTRAReport DevExpress) Error: It is being used by another process导出为 PDF (XTRAReport DevExpress) 错误:它正被另一个进程使用
【发布时间】:2014-02-12 17:07:20
【问题描述】:

我这里有这段代码,可以将创建的 XtraReport 导出为 PDF 文件。但是我收到一条错误消息,上面写着“它正在被另一个进程使用。”

我有办法避免这个错误吗?我尝试使用 System.IO.File.Delete 删除文件,但它不断收到错误消息。另外,考虑到我确实需要使用相同的文件名。

代码如下:

 Dim ReturnText As String = ""

    Dim dtReport As DataTable = Nothing

    Dim dtRows() As DataRow = Nothing

    Dim XRPath As String = "reports/travel.repx"

    Dim XRSubPath As String = "reports/travel_costallocation.repx"

    Dim SQL As String = String.Empty

    Dim xrBandTag As String = String.Empty

    Dim xrGroupField As GroupField = Nothing

    Dim xrProtectBands As String = "[BottomMargin][PageFooter][PageHeader][ReportHeader]"

    Dim xrFilename As String = String.Empty

    Dim xParams As Integer = 0

    Dim dAccessTo As DataTable = Nothing

    Dim bUpdate As Boolean = False

    Dim ReportID As Integer = 0

    Dim ReportData() As Object = Nothing

    Dim Value() As String = Nothing

    Dim xrReport As XtraReport = Nothing

   'manipulate report here

 xrReport.ExportToPdf(ServerPath & "\documents\travelpdf\eTravelNo_" & PathID & ".pdf")

感谢您的提前帮助。

【问题讨论】:

    标签: vb.net devexpress xtrareport


    【解决方案1】:

    在这种情况下,简单的解决方案是使用 try catch 处理代码中的异常,如果文件被锁定,则向用户提示解锁文件的消息。

    按照以下链接检查文件是否正在使用中

    Is there a way to check if a file is in use?

    Checking if a file is in use without try catch?

    【讨论】:

      猜你喜欢
      • 2015-08-12
      • 2015-08-22
      • 2023-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多