本文介绍了如何在ASP.NET中获取虚拟文件夹的物理路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取虚拟文件夹的物理路径(required_folder
)?当前文件夹和required_folder
是不同的根虚拟文件夹的物理路径;文件夹和required_folder
位于同一根物理文件夹中.
下一个代码没有帮助:
How to get phisical path (required_folder
) to virtual folder? Current folder and required_folder
are phisical pathes of different root virtual folders; folder and required_folder
are in the same root phisical folder.
The next code didn''t help:
string folder = Server.MapPath(""); // get current folder
folder = folder.Substring(0, folder.LastIndexOf('\\') + 1) + "required_folder"; // get required folder
推荐答案
string folder = Server.MapPath("~/required_folder/");
将返回required_folder
文件夹的物理路径.
will return the physical path of the required_folder
folder.
string req_folder= Server.MapPath("~/required_folder/");
谢谢
thanks
这篇关于如何在ASP.NET中获取虚拟文件夹的物理路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!