日期:2014-05-17  浏览次数:20491 次

ASP.NET图片前台显示的问题
后台已经将图片上传至服务器的Upload文件夹

Upload下面会根据类别分成A,B,C,D,E五个文件夹

怎么可以设定将动态选中的文件夹的所有图片读到页面显示?
  
例如将A,C,D的文件夹的图片显示在页面上

------解决方案--------------------
System.IO.FileInfo[] fs1 = (new System.IO.DirectoryInfo(Server.MapPath("~/A"))).GetFiles();
System.IO.FileInfo[] fs2 = (new System.IO.DirectoryInfo(Server.MapPath("~/B"))).GetFiles();
System.IO.FileInfo[] fs3 = (new System.IO.DirectoryInfo(Server.MapPath("~/C"))).GetFiles();
System.IO.FileInfo[] fs4 = (new System.IO.DirectoryInfo(Server.MapPath("~/D"))).GetFiles();
System.IO.FileInfo[] fs5 = (new System.IO.DirectoryInfo(Server.MapPath("~/E"))).GetFiles();
var fs = fs1.Concat(fs2).Concat(fs3).Concat(fs4).Concat(fs5);
GridView1.DataSource =fs;
GridView1.DataBind();
------解决方案--------------------
孟老师 你这样获取到的文件名称是本地绝对路径 需要转换成url的
探讨

GridView1里面
<img src='<%#Eval("FileName")%>' />