473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Server.MapPath("/");

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?
Nov 18 '05 #1
1 1803
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/
----------------------------------
Making waves on the Web
"Jim Heavey" <Ji*******@nospam.com> wrote in message
news:Xn*********************************@207.46.24 8.16...
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?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
3
by: Mikkky | last post by:
The sample code below returns and error " The type or namspace name 'Server' could not be found". Please help. using System;using System.IO; using System.Xml;using System.Diagnostics; using...
4
by: ramonred | last post by:
txtUpload1.PostedFile.SaveAs(Server.MapPath("~") + "\\" + file1.Name); this code loads the file in the root directory of my application, by using the tilde. How do I accomplish getting the file...
2
by: Tee | last post by:
Hi, I am currently using Server.MapPath in my aspx files, but because of I am using it more than once, I would like to move these code away from aspx and make it as a public function inside...
0
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and...
2
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and...
10
by: Kenneth P | last post by:
Hi all, I have an Access database and try to create a connection to it using the Server.MapPath method. I have the app lib in c:\inetprub\wwwroot\apps\myApp and the database in...
1
by: ae | last post by:
is the prope way to read xml files, as long as they are on my server, but how do i access them from other sites, such as http://www.site.com/xmltoread.xm
5
by: MichiMichi | last post by:
When using Server.MapPath on IIS 5 on my localhost everything works well. All of the following commands are executed without any error Response.Write(Server.MapPath("/app_test") & "<br>")...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.