Print Page | Close Window

Invalid Report File Path in C#

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22129
Printed Date: 04 May 2024 at 2:29am


Topic: Invalid Report File Path in C#
Posted By: tiamsicb
Subject: Invalid Report File Path in C#
Date Posted: 03 Nov 2016 at 12:56pm
Hi, I am unsure why I am getting this error "Invalid report file path"



Image url: https://www.dropbox.com/s/zudkbb442u73e1j/Invalid%20Report%20File%20Path.JPGdl=0

I am 100% sure that the report is in the correct path, I even tried to put the entire path (e.g. C:\Users\IAmTheUser\Desktop\MyProject\Reports\MyReport.rpt

Here is my code:

ReportDocument rptDoc = new ReportDocument();
        string strRptLoad = Server.MapPath("../Reports/MyReport.rpt");
        rptDoc.Load(strRptLoad);
        //rptDoc.Load("C:\\Users\\IAmTheUser\\Desktop\\MyProject\\Reports\\MyReport.rpt");

        DataSetPrintAll.spSelectReimbursePrintAllDataTable dt = new DataSetPrintAll.spSelectReimbursePrintAllDataTable();
        dtPrintAllAdapter printAdapter = new dtPrintAllAdapter();

        dt = printAdapter.GetData(transactionNo);
        DataSet ds = new DataSet();
        ds.Tables.Add(dt);

        rptDoc.SetDataSource(ds);
        crPrint.ReportSource = rptDoc;
        crPrint.DataBind();
        crPrint.DocumentView = CrystalDecisions.Shared.DocumentViewType.PrintLayout;
        crPrint.Dispose();


-------------
Every start is hard for us but as time pass, everything will be a piece of cake



Replies:
Posted By: Crystal-Newbie
Date Posted: 03 Nov 2016 at 11:05pm
You have double backslashes setup:

("C:\\Users\\IAmTheUser\\Desktop\\MyProject\\Reports\\MyReport.rpt");

should it not be:

("C:\Users\IAmTheUser\Desktop\MyProject\Reports\MyReport.rpt");

?


Posted By: tiamsicb
Date Posted: 06 Nov 2016 at 12:01pm
If I am to use single "/", I should add "@" for it to be read as string and it is the same.

-------------
Every start is hard for us but as time pass, everything will be a piece of cake



Print Page | Close Window