Search code examples
c#vb.netcrystal-reports

Find report file outside of Application.StartupPath or bin folder


My Crystal Report is located outside of Application.StartupPath and the bin folder - in a tree folder:

MainFolder
  - CrystalReport_here_which_is_Sales_report.rpt
bin 'folder
  - DebugFolder
    - inside debug folder is the application startup 

I used this code but it cannot locate the file - How can I resolve this?

rpt.Load(Application.StartupPath & "\Sales_Report.rpt")

Solution

  • You can solve your problem with a relative path (code in vb.net) :

    Dim CRPath as String = System.IO.Path.GetDirectoryName(Application.StartupPath) & "\..\..\MainFolder\"
    rpt.Load(CRPath & "Sales_Report.rpt")