.net 怎么获取文件夹的图片

前台

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

后台:

string path = Server.MapPath("img");//获取img文件夹的路径 
Response.Write(path); 
DirectoryInfo di = new DirectoryInfo(path); 
//DataList1.DataSource = di.GetFiles("*.jpg");只获取jpg图片 
DataList1.DataSource = di.GetFiles();//获取文件夹下所有的文件 
DataList1.DataBind(); 

  

  

原文地址:https://www.cnblogs.com/guozhe/p/2824616.html