Server.MapPath("/");

J

Jim Heavey

Hello, I am trying out how to programatically figure out where my datafile
is. I thought I could use Server.MapPath to provide me the name of where
my webpage is located, as I have used that in other situations, but this
situation is different. My web pages and data file do not reside on the
same drive as where the server resides, so Sever.MapPath is propbably not
the right method.

How do I find the path where my actual web page is located?

My goal is to have the file name in the "web.config" file and retrieve the
Location of where my web page is and append the folder name of "\Data\" and
then append the file name that I retrieved from the web config file.

Is there a way for me to do this?
 
R

Rick Strahl [MVP]

Request.PhysicalPath is probably what you want to figure out the full
current path of your page. If you're trying to figure out the path of a
control or other relatively loaded component you can use the TemplateSource
path off the WebControl class.

I posted an entry in my Web Log a while back about the different paths and
what they mean here:

http://west-wind.com/weblog/posts/269.aspx

As to reading data out of the Config file you can use the
ConfigurationSettings.AppSettings object to retrieve this.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top