Server.Mappath() method

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
 
M

Mattias Sjögren

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
 
J

Jane

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top