Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在我的项目文件夹/wwwroot文件夹外的mvc3中检索图像路径_C#_Image_Asp.net Mvc 3_Path_Imageview - Fatal编程技术网

C# 在我的项目文件夹/wwwroot文件夹外的mvc3中检索图像路径

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

嗨,我被困了一个小时来修复从“D:\Sample”路径检索的图像。我正在检索正确的路径,但没有显示,因为localhost:port“(mylocalhosthere):(port)/D:/Sample/sample1.jpg”。如何在项目路径之外显示图像?谁来帮帮我。非常感谢。这是我的密码:

控制器:

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' />
}