mappath?

M

majiofpersia

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
 
M

majiofpersia

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
 
B

Bill Priess

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.
 

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

Top