Server.MapPath question

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

In my code I have this line of code....
CrystalReportViewer1.ReportSource =
Server.MapPath("CrystalReportSummary.rpt")

I moved the file, CrystalReportSummary.rpt, and I get an error.

The value for Server.MapPath("CrystalReportSummary.rpt") is the old path,
not the new one.

Is this not supposed to be dynamic? How can I correct this?


Thanks
 
Server.MapPath just transforms a "URL" path into a physical path. It doesn't
care where the file is or even if a file named this way exists.
Server.MapPath("file.txt") will just return a path to this file (wether it
exists or not) relative to the directory of the currently executing page.

You'll have to fix the path in Server.MapPath such as
Server.MapPath("~/myreports/CrystalReportSummary.rpt").

See the doc for details...
 
Back
Top