asp.net 获取文件夹中的图片的代码

前台:
复制代码 代码如下:

CellSpacing="25">

" width="50" height="50" border="0" >



后台代码:
复制代码 代码如下:

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();

你可能感兴趣的:(asp.net 获取文件夹中的图片的代码)