string[] strImage = Directory.GetFiles(Server.MapPath("~/userphoto/"));
DataTable dt_image = new DataTable();
dt_image.Columns.Add("images");
foreach (string str in strImage)
{
string strUrl = "userphoto/" + str.Substring(str.LastIndexOf("\\"), str.Length - str.LastIndexOf("\\"));
dt_image.Rows.Add(strUrl.Replace("/\\", "/"));
}
dlContent.DataSource = dt_image;
dlContent.DataBind();
时间: 2024-10-27 19:33:41