mappath?

  • Thread starter Thread starter majiofpersia
  • Start date Start date
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
 
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
 
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.
 
Back
Top