Server.Mappath() method

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

Hello,

I used Server.MapPath(mypath) method to find an absolute
path of a file on a web server. But I got error message -
Name 'Server' is not declared. I have imported System.IO.
Does someone know any tricky here?

Thanks in advance.

Jane
 
Jane,
I used Server.MapPath(mypath) method to find an absolute
path of a file on a web server. But I got error message -
Name 'Server' is not declared. I have imported System.IO.
Does someone know any tricky here?

Where's your code located? Server is a property of the
System.Web.UI.Page class so you have to put the code inside your page
class, or pass a reference to the Page object to the method where you
want to use Server.MapPath.

System.IO has nothing to do with it.



Mattias
 
Thanks so much, Mattias.

I am developing a windows application that checks if a
particular web page is on the web server. When I use
system.IO.File.Exists(path) method to check it, path
parameter has to be an absolute path. But I only know
virtual path. Is there any other methods I can use to find
an absolute path of a web page in a windows application?

Jane
 
Back
Top