string bookNo = "01";
bookNo = Request.Params["no"] == null ? "01" : Request.Params["no"];
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/_img/bookImg/" + bookNo));
if(!dir.Exists){
dir = new DirectoryInfo(Server.MapPath("~/_img/bookImg/01"));
bookNo = "01";
}
FileInfo[] files = dir.GetFiles();
StringBuilder sb = new StringBuilder();
foreach (FileInfo file in files)
{
sb.Append("<img src='' data-original='_img/bookImg/" + bookNo + "/" + file.Name + "' style='width:100%;' />");
}
bookImg.InnerHtml = sb.ToString();
- May 06 Fri 2016 11:54
C# 載入資料夾內所有圖片
close
全站熱搜
留言列表