读书人

ASP.NET图片前台显示的有关问题

发布时间: 2012-08-11 20:50:31 作者: rapoo

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")%>' />

读书人网 >asp.net

热点推荐