我在我的应用程序文件夹下有一个文件夹的。我想提供到该文件夹中的文件的链接。该文件夹可能有子文件夹,等等。如何在链接中提供http urls。
当我这样做时,我只得到文件的物理位置,而不是http url。
Path.Combine(file.DirectoryName, file.Name)谢谢。
发布于 2013-08-07 21:24:14
首先获取应用程序的根。
var root = Server.MapPath("~");现在,做您需要的事,遍历文件/目录。您可以简单地组合这样的路径:
foreach (var file in System.IO.Directory
.GetFiles(System.IO.Path.Combine(root, "Images")))
{
// This will give you the relative URL of each file.
var fileUrl = ResolveUrl(file.Replace(root, string.Empty).Replace("\\", "/"));
}https://stackoverflow.com/questions/18113860
复制相似问题