Server.MapPath question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Craig

    Server.MapPath question

    In my code I have this line of code....
    CrystalReportVi ewer1.ReportSou rce =
    Server.MapPath( "CrystalReportS ummary.rpt")

    I moved the file, CrystalReportSu mmary.rpt, and I get an error.

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

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


    Thanks


  • Patrice

    #2
    Re: Server.MapPath question

    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/CrystalReportSu mmary.rpt").

    See the doc for details...

    --

    Patrice

    "Craig" <NoSpam@hotmail .com> a écrit dans le message de
    news:%23wmOTxK0 FHA.2064@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > In my code I have this line of code....
    > CrystalReportVi ewer1.ReportSou rce =
    > Server.MapPath( "CrystalReportS ummary.rpt")
    >
    > I moved the file, CrystalReportSu mmary.rpt, and I get an error.
    >
    > The value for Server.MapPath( "CrystalReportS ummary.rpt") is the old path,
    > not the new one.
    >
    > Is this not supposed to be dynamic? How can I correct this?
    >
    >
    > Thanks
    >
    >[/color]


    Comment

    Working...