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

mappath?

Hi all,
I am confused the mappath does not support virtual directories any more? I
realize that the ".." for the virtual directory to go to a higher level root
is not supported in .NET any longer ... but I can't get the mappath to work
with the backslash/forwardslash/ and no-slash to work either ... I have
tried pretty much every combination ... any ideas as what I am doing wrong
is appreciated ... Here is what I am trying to achieve ...

my code in directory:
c:/inetpub/wwwroot/practice/test.aspx

my file in directory
c:/inetpub/wwwroot/files/text.txt

in the code I want to get to the text file without providing the whole
physical path ..
I have tried the following and get errors for all of them... (in C#)

mappath("/files/text.txt"); - file not found in practice/files directory
mappath("\\files\\text.txt"); - file not found in practice/files directory
mappath("\files\text.txt"); - escape character error which makes sense
mappath("files\text.txt"); - file not found in practice/files directory
mappath("files/text.txt"); - file not found in practice/files directory

What am I doing wrong??

Thanks in advance,

- Maji

Nov 15 '05 #1
4 9958
your suggestion does not work ...
I tried it and I get the same error ....

Does anyone know of a setting on IIS that might be affecting this?

Thanks in advance,

-Maji

"Jeff Mankato" <no*@me.com> wrote in message
news:pa****************************@me.com...
On Thu, 31 Jul 2003 14:24:27 -0700, majiofpersia wrote:


my code in directory:
c:/inetpub/wwwroot/practice/test.aspx

my file in directory
c:/inetpub/wwwroot/files/text.txt

Why not use the '~' in mappath to signify the root of the web that the
page is sitting on?
i.e. MapPath("~/files/text.txt")

Nov 15 '05 #2
your suggestion does not work ...
I tried it and I get the same error ....

Does anyone know of a setting on IIS that might be affecting this?

Thanks in advance,

-Maji

"Jeff Mankato" <no*@me.com> wrote in message
news:pa****************************@me.com...
On Thu, 31 Jul 2003 14:24:27 -0700, majiofpersia wrote:


my code in directory:
c:/inetpub/wwwroot/practice/test.aspx

my file in directory
c:/inetpub/wwwroot/files/text.txt

Why not use the '~' in mappath to signify the root of the web that the
page is sitting on?
i.e. MapPath("~/files/text.txt")

Nov 15 '05 #3
Funny, I was able to get it to work fine...

Response.Write(Server.MapPath("../files/text.txt"));

outputted: c:\inetpub\wwwroot\files\text.txt

and I ran it from http://localhost/projects/webform1.aspx..
Where is it documeneted that .NET does not support the ".." anymore?

HTH,

Bill P.

On Thu, 31 Jul 2003 14:24:27 -0700, majiofpersia <ma**********@yahoo.com>
wrote:
Hi all,
I am confused the mappath does not support virtual directories any more?
I
realize that the ".." for the virtual directory to go to a higher level
root
is not supported in .NET any longer ... but I can't get the mappath to
work
with the backslash/forwardslash/ and no-slash to work either ... I have
tried pretty much every combination ... any ideas as what I am doing
wrong
is appreciated ... Here is what I am trying to achieve ...

my code in directory:
c:/inetpub/wwwroot/practice/test.aspx

my file in directory
c:/inetpub/wwwroot/files/text.txt

in the code I want to get to the text file without providing the whole
physical path ..
I have tried the following and get errors for all of them... (in C#)

mappath("/files/text.txt"); - file not found in practice/files directory
mappath("\\files\\text.txt"); - file not found in practice/files
directory
mappath("\files\text.txt"); - escape character error which makes sense
mappath("files\text.txt"); - file not found in practice/files directory
mappath("files/text.txt"); - file not found in practice/files directory

What am I doing wrong??

Thanks in advance,

- Maji



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4
Funny, I was able to get it to work fine...

Response.Write(Server.MapPath("../files/text.txt"));

outputted: c:\inetpub\wwwroot\files\text.txt

and I ran it from http://localhost/projects/webform1.aspx..
Where is it documeneted that .NET does not support the ".." anymore?

HTH,

Bill P.

On Thu, 31 Jul 2003 14:24:27 -0700, majiofpersia <ma**********@yahoo.com>
wrote:
Hi all,
I am confused the mappath does not support virtual directories any more?
I
realize that the ".." for the virtual directory to go to a higher level
root
is not supported in .NET any longer ... but I can't get the mappath to
work
with the backslash/forwardslash/ and no-slash to work either ... I have
tried pretty much every combination ... any ideas as what I am doing
wrong
is appreciated ... Here is what I am trying to achieve ...

my code in directory:
c:/inetpub/wwwroot/practice/test.aspx

my file in directory
c:/inetpub/wwwroot/files/text.txt

in the code I want to get to the text file without providing the whole
physical path ..
I have tried the following and get errors for all of them... (in C#)

mappath("/files/text.txt"); - file not found in practice/files directory
mappath("\\files\\text.txt"); - file not found in practice/files
directory
mappath("\files\text.txt"); - escape character error which makes sense
mappath("files\text.txt"); - file not found in practice/files directory
mappath("files/text.txt"); - file not found in practice/files directory

What am I doing wrong??

Thanks in advance,

- Maji



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #5

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

Similar topics

4
by: Supertzar | last post by:
Hi, I'm trying to use MapPath on a folder named with a comma in it: xmldoc.load Server.MapPath(Request.QueryString("fname")) where the querysting is something like "fname=this, that/this,...
13
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a...
0
by: majiofpersia | last post by:
Hi all, I am confused the mappath does not support virtual directories any more? I realize that the ".." for the virtual directory to go to a higher level root is not supported in .NET any longer...
7
by: benoit | last post by:
Hi, if I write this code to retrieve a folder on the server Server.mappath("/DATA") I get this error message System.InvalidOperationException: Failed to map the path '/DATA' the virtual...
7
by: teo | last post by:
I need to use the 'Server.MapPath' function in the 'Session_End' event of the Global.asax file (to reach a folder and the clean some temporary files up), but it doesn't work: Sub...
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>")...
4
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
3
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have one line code in my program, occasionaly I will receive the following error: "The Path parameter for the MapPath method did not correspond to a known path" ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.