C# 在我的项目文件夹/wwwroot文件夹外的mvc3中检索图像路径
嗨,我被困了一个小时来修复从“D:\Sample”路径检索的图像。我正在检索正确的路径,但没有显示,因为localhost:port“(mylocalhosthere):(port)/D:/Sample/sample1.jpg”。如何在项目路径之外显示图像?谁来帮帮我。非常感谢。这是我的密码: 控制器:C# 在我的项目文件夹/wwwroot文件夹外的mvc3中检索图像路径,c#,image,asp.net-mvc-3,path,imageview,C#,Image,Asp.net Mvc 3,Path,Imageview,嗨,我被困了一个小时来修复从“D:\Sample”路径检索的图像。我正在检索正确的路径,但没有显示,因为localhost:port“(mylocalhosthere):(port)/D:/Sample/sample1.jpg”。如何在项目路径之外显示图像?谁来帮帮我。非常感谢。这是我的密码: 控制器: public class UploadController : Controller { // // GET: /Upload/ public ActionResult
public class UploadController : Controller
{
//
// GET: /Upload/
public ActionResult Index()
{
const string root = @"D:\Sample";
var all = Directory.GetFiles(root).Select(Path.GetFullPath).ToArray();
return View(all);
}
}
}
视图:
@{
ViewBag.Title=“Index”;
}
@模型字符串[]
@foreach(模型中的var图像)
{
var aaa=System.IO.Path.GetFileNameWithoutExtension(image);
}
可能重复@RGraham no,我正在寻找在我的项目文件夹外显示图像..ex。在我的驱动器D中,该问题包含答案。
@{
ViewBag.Title = "Index";
}
@model string[]
@foreach(var image in Model)
{
var aaa = System.IO.Path.GetFileNameWithoutExtension(image);
<img src="@Url.Content(image)" alt='@aaa'/>
<input type="checkbox" id= '@aaa' />
}