title: Export to PDF (XTRAReport DevExpress) Error: It is being used by another process
body: <p>I have this code here that exports the XtraReport created to PDF File. But I get an error message that says "It is being used by another process."</p>
  
  <p>Is there a way for me to avoid this error? I tried deleting the file by using System.IO.File.Delete but it keeps getting the error message. Also, considering that I really need to use the same file name.</p>
  
  <p>here's the code:</p>
  
  <pre><code> 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 &amp; "\documents\travelpdf\eTravelNo_" &amp; PathID &amp; ".pdf")
  </code></pre>
  
  <p>Thank you for the advance help.</p>