Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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#_C#_Css_Asp.net Mvc 4 - Fatal编程技术网

画廊文件夹封面照片使用C#

画廊文件夹封面照片使用C#,c#,css,asp.net-mvc-4,C#,Css,Asp.net Mvc 4,我正在用C#在ASP.NET MVC 4中完成我的项目。我的网站上有一个图库页面。为了在gallery文件夹中列出每个相册文件夹,我使用以下代码: 型号: public List<string> GetGalleryName(string path) { DirectoryInfo di = new DirectoryInfo(path); DirectoryInfo[] subdir = di.GetDirectories(); List<string

我正在用C#在ASP.NET MVC 4中完成我的项目。我的网站上有一个图库页面。为了在gallery文件夹中列出每个相册文件夹,我使用以下代码:

型号:

public List<string> GetGalleryName(string path)
{
    DirectoryInfo di = new DirectoryInfo(path);
    DirectoryInfo[] subdir = di.GetDirectories();
    List<string> files = new List<string>();
    foreach (DirectoryInfo dir in subdir)
    {
        files.Add(dir.Name);
    }
    return files;
}
public List GetGalleryName(字符串路径)
{
DirectoryInfo di=新的DirectoryInfo(路径);
DirectoryInfo[]subdir=di.GetDirectories();
列表文件=新列表();
foreach(子目录中的目录信息目录)
{
files.Add(目录名);
}
归还文件;
}
控制器:

public ActionResult Gallery()
{
    string folderpath = Server.MapPath("~/Images/Gallery");
    List<String> currentimage = new Gallery().GetGalleryName(folderpath);
    return View(currentimage);
}
public ActionResult库()
{
字符串folderpath=Server.MapPath(“~/Images/Gallery”);
List currentimage=new Gallery().GetGalleryName(folderpath);
返回视图(currentimage);
}
cshtml:

@foreach(var item in Model)
{
<a href="~/Home/Show?foldername=@item"> <div class="galframe"><div class="galframepic"></div><div class="galframecaption"><p>@item</p></div></div></a>
}
@foreach(模型中的变量项)
{
}

我想通过使用特定文件夹(如Facebook相册)中的图像来设置封面或每个相册文件夹。实际上,该特定文件夹中的一个图像显示为div“galframepic”的背景。我该怎么做呢?

我使用asp.net webform完成了几乎相同类型的任务。我正在分享我的工作流程,看看它是否对你有所帮助

1. Create an entry form for album. In this form there will be two input fields
  a) Album name field of type text
  b) file type input field.
  c) when album name is given and an image file is uploaded to a certain directory then save  the directoryPath+imageFileName in your database along with the Album name.

2) In another page fetch the previously save data for the album from database. And use image that was uploaded in the directory as the cover folder of the album. you can also show the album name that is fetched along with the (directoryPath+imageFileName) below the image.
希望这有帮助, 谢谢