我已经编写了以下代码,
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(@"C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt");Report对上面的代码工作得很好,但我想给出一个相对路径,这样我就可以在不更改路径的情况下将其安装在多台机器上。我还尝试了以下方法
string loc = AppDomain.CurrentDomain.BaseDirectory;
string loc2 = Application.StartupPath;
string loc3 = Application.UserAppDataPath;
string loc4 = Application.CommonAppDataPath; 把它们当做
report.Load(loc2 + "\\ReportSalesInvoice.rpt");但该文件不能是accessed.Please帮助。
发布于 2012-06-28 05:14:56
没有在windows应用程序中测试过,但这是我在MVC3中使用的。不过,我认为相对路径必须位于应用程序的根目录中
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using (var report = new ReportClass { FileName = Server.MapPath("/AppName/Reports/MyReport.rpt") })
{
report.Load();
...发布于 2016-02-14 10:51:57
private void Crystal_rpt()
{
ReportDocument dir = new ReportDocument();
dir = functions.Show_Crystal_rpt();
dir.Load(Application.StartupPath + "\\rptObt_mark.rpt");
crpMark_sheet.ReportSource = dir;
}https://stackoverflow.com/questions/11212358
复制相似问题