By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

How to get Full Path of current directory ? (ASP.net)

P: n/a
Hi,

I want to retrieve the complete full path to the directory
of my current page but i don't find how to do that.
For example i want : D:\myWebSite\firstDotNetWebApp\dir1\

I tried "AppDomain.CurrentDomain.BaseDirectory" but it's
return only the path to my WebApplication, ex :
D:\myWebSite\firstDotNetWebApp\

Some how to do that ?

thx
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
SSW
Server.MapPath("MyWebSite");

HTH

Thanks,

sswalia

"PHaroZ" <se*****************@douane.finances.gouv.fr> wrote in message
news:0b****************************@phx.gbl...
Hi,

I want to retrieve the complete full path to the directory
of my current page but i don't find how to do that.
For example i want : D:\myWebSite\firstDotNetWebApp\dir1\

I tried "AppDomain.CurrentDomain.BaseDirectory" but it's
return only the path to my WebApplication, ex :
D:\myWebSite\firstDotNetWebApp\

Some how to do that ?

thx

Nov 18 '05 #2

P: n/a
"PHaroZ" wrote...
Some how to do that ?


Server.MapPath( Path)

** Copied from a search in Visual Studio for mappath **

For the examples below, the file Data.txt is located in the directory,
C:\Inetpub\Wwwroot\Script, along with the Test.asp file that contains the
following scripts. The C:\Inetpub\Wwwroot directory is set as the server's
home directory.

The following example uses the server variable PATH_INFO to map the physical
path of the current file.

<%= Server.MapPath(Request.ServerVariables("PATH_INFO" ))%><BR>

The preceding script produces the following output:

c:\inetpub\wwwroot\script\test.asp<BR>

Because the path parameters in the following examples do not start with a
slash character, they are mapped relative to the current directory, in this
case C:\Inetpub\Wwwroot\Script.

<%= Server.MapPath("data.txt")%><BR>
<%= Server.MapPath("script/data.txt")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot\script\data.txt<BR>
c:\inetpub\wwwroot\script\script\data.txt<BR>

The next two examples use the slash characters to specify that the path
returned should be looked up as complete virtual paths on the server.

<%= Server.MapPath("/script/data.txt")%><BR>
<%= Server.MapPath("\script")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot\script\data.txt<BR>
c:\inetpub\wwwroot\script<BR>

The following examples demonstrate how you can use either a forward slash
(/) or a backslash (\) to return the physical path to the home directory of
the Web site root.

<%= Server.MapPath("/")%><BR>
<%= Server.MapPath("")%><BR>

The preceding scripts produce the following output:

c:\inetpub\wwwroot<BR>
c:\inetpub\wwwroot<BR>

The following example demonstrates how you can use relative paths to return
the relative physical path to the page that is being viewed in the Web
browser.

<%= Server.MapPath("../")%><BR>
<%= Server.MapPath("..")%><BR>

Hope this helps.

Regards

Rob
Nov 18 '05 #3

P: n/a
Jos
Server.MapPath(".")

--

Jos
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.