473,325 Members | 2,785 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,325 software developers and data experts.

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

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
3 25624
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
"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
Jos
Server.MapPath(".")

--

Jos
Nov 18 '05 #4

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

Similar topics

8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
2
by: Anders Bornholm | last post by:
I have the following setup: A website that is completely accessible to a logged-in user. Access control is handled by a third-party external module implemented as an ISAPI filter. The...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
4
by: tommaso.gastaldi | last post by:
Hi friends I was in the need to find a sort of "definitive" :) solution to transform a virtual path such as "~/MyDir/MyFile into a full web address. In particular I needed it * within web...
7
by: gmax2006 | last post by:
Hi, I use RedHat linux. How can I find where exactly the current python script is running? I use this code: #test.py import os,sys
1
by: xeroxero | last post by:
With Framework 2.0, what is the best way to get the current full URI of the web application? For example, if a user goes to http://mysite.com/place/subdir and the virtrual directory (web app)...
1
by: jalupinu | last post by:
My OS is Winxp SP2 and the software I am having trouble with is Maximizer 9.5 Enterprise. It has a Web Portal feature that i am trying to use and followed the instructions to set it up however I keep...
4
by: Michel Rouzic | last post by:
I made a program that accepts as parameters an input file name that we'll call file1, and an output file name that we'll call file2, and opens on its own a configuration file called file3. My...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.