读取文件夹中的图片,显示在datalist中

在app_Image文件夹中有一些图片,我想显示在页面中,就是打开本页面的时候显示所有的图片,
我在页面中用datalist控件控制图片
读取图片后台:

void dobindPicture()

{

string url = System.Web.HttpContext.Current.Server.MapPath(Request.ApplicationPath+"/App_Images/TopImages/");

DirectoryInfo di = new DirectoryInfo(url );


articleList.DataSource = di.GetFiles("*.jpg");
       
articleList.DataBind();

}

前台:

<asp:DataList ID="articleList" runat="server" RepeatDirection="Horizontal" RepeatColumns="3"
                CellSpacing="25">
                <ItemTemplate>
                    <img src="<%# Eval("FullName") %>" width="32" height="32" border="0" >
                </ItemTemplate>
            </asp:DataList>

di.GetFiles("*.jpg"):这个中读出的是所有文件夹中的内容,其中FullName表示该图片的地址,Name表示图片的名称.还有时间,文件夹大小等属性.

原文地址:https://www.cnblogs.com/flyrain/p/DirectoryInfo.html