本文介绍了“无效的报告文件路径” C#水晶报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定为什么我收到此错误无效的报告文件路径

图片:





I我100%确定报告的路径是正确的,我甚至试图把整个路径放在一边(例如C:\ Users\IAmTheUser \Desktop \ MyProject \ Reportport \ MyReport.rpt



我尝试过:



Hi, I am unsure why I am getting this error "Invalid report file path"
Image: Click me to view image of error


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

What I have tried:

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();

推荐答案

string strRptLoad = Server.MapPath("/Reports/MyReport.rpt"); //remove double dots ..





通常在指定Server.MapPath时 - 它会为您提供应用程序目录的根目录,然后按照里面的文件夹进行操作。

您可以在任何页面中使用Server.MapPath - 无论这些页面是否在应用程序的子目录中都无关紧要 - 它将为您提供应用程序目录的根目录然后您将拥有如示例所示引导内部文件夹。



希望这有帮助,不要忘记将其标记为解决方案,如果它有效..



干杯



Generally when you specify Server.MapPath - it gives you the root of the application directory and then follow the folders inside.
You can use Server.MapPath from within any pages - does not matter whether those pages are within sub directories in the application or not - It will give you the root of the application directory and then you would have to guide through inner folders as in the example.

Hope this helps and don't forget to mark this as a solution if it works..

Cheers


这篇关于“无效的报告文件路径” C#水晶报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 08:02