Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I am writing an application in asp.net. My current page is in this folder:
D:\VisualStudio2015\Source\VestVB\admin\abc.aspx. 
I want to go to the folder of D:\VisualStudio2015\Source. 
when I write the code: Response.write(Server.MapPath(".")), 
I got: D:VisualStudio2015\Source\VestVB\admin. 
if I change the code to server.mapPath(".."), 
I got D:VisualStudio2015\Source\VestVB. 
if I change the code to server.mapPath("../..")
I got ERROR: Cannot use a leading .. to exit above the top directory. 
How can I get to D:VisualStudio2015\Scource?

thanks in advance.


What I have tried:

I have tried both mapPath("~") and mapPath("../.."), both don't work for me.
Posted
Updated 3-Dec-16 11:54am

1 solution

You can't, for security reasons. It's that simple.

The TOP of your application is D:\VisualStudio2015\Source\VestVB\admin. Your code can never navigate above that folder.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900