本文介绍了为什么mappath(“〜”)没有返回我的应用程序根目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!!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. 我尝试了什么: 我已经尝试了mapPath(〜)和mapPath(../ ..),两者都是不能为我工作。What I have tried:I have tried both mapPath("~") and mapPath("../.."), both don't work for me.推荐答案出于安全考虑,你不能这样做。就这么简单。 您的应用程序的顶部是D:\ VisisStudio2015 \ Source \VestVB \ admin。您的代码永远不会在该文件夹上方导航。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. 这篇关于为什么mappath(“〜”)没有返回我的应用程序根目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 16:52