// YourPage.aspx
<%@ Import Namespace="System.IO" %>
<html>
<body>
<% foreach (var dir in new DirectoryInfo("E:\\TEMP").GetDirectories()) { %>
Directory: <%= dir.Name %><br />
<% foreach (var file in dir.GetFiles()) { %>
<%= file.Name %><br />
<% } %>
<br />
<% } %>
</body>
</html>
我服用中的版本:
<ul> <% System.IO.DirectoryInfo diFiles = new System.IO.DirectoryInfo(Server.MapPath("/ImgUpload/")); foreach (var f in diFiles.GetFiles()) { Response.Write("<li><img src='/ImgUpload/" + f.Name + "' width='200'/></li>"); } %> </ul>