<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#ul_photo li { width: 13em; height: 13em; margin: 1.5em; border: solid 1px #ccc; float: left; overflow: hidden; text-align: center; }
#ul_photo li img { width: 110px; height: 103px; border: 0px; margin-top: 10px; }
#txtDirName { font-size: 12px; color: #dedede; width: 200px; }
.sspan { cursor: pointer; margin-top: 1em; }
#btnSelect { display: none; }
.margtbtdb td { line-height: 24px; font-size: 14px; }
a:link, a:visited { color: #666666; }
a:hover { color: Red; }
</style>
</head>
<body>
<form runat="server">
<table class="marg_tb" cellpadding="0" cellspacing="0" style="border-top: 0px">
<tr>
<td class="margtbtdc">
<img src="../images/martb.png" />静态文件资源库
</td>
</tr>
<tr>
<td class="margtbtdb">
<table id="filetb" style="text-align: center">
<tr>
<th>
<a href="javascript:void(0)" onclick="ckSelectAll('filetb')" />全选</a>
</th>
<th style="width: 360px; text-align: left;">
<asp:LinkButton ID="lkFileName" runat="server" oncommand="lkFileName_Command">文件名</asp:LinkButton>
</th>
<th style="width: 100px">
<asp:LinkButton ID="LinkButton2" runat="server">类型</asp:LinkButton>
</th>
<th style="width: 60px">
<asp:LinkButton ID="LinkButton3" runat="server">大小</asp:LinkButton>
</th>
<th style="width: 186px">
<asp:LinkButton ID="LinkButton4" runat="server">文件创建时间</asp:LinkButton>
</th>
<%--<th style="width: 186px">
文件修改时间
</th>--%>
</tr>
<asp:Repeater ID="rptPhoto" runat="server">
<ItemTemplate>
<tr>
<td>
<input runat="server" id="ckItem" value='<%#Eval("FilePath") %>' type="checkbox" />
</td>
<td style="width: 360px; text-align: left;">
<a target="_blank" title="点击查看" href='<%# Eval("FileName","../../{0}") %>'>
<%# Eval("FileName") %></a>
</td>
<td>
静态页面
</td>
<td>
<%# Eval("FileSize").ToString()+"kb" %>
</td>
<td>
<%# Eval("CreateDate").ToString()%>
</td>
<%--<td>
<%# Eval("UpdateDate").ToString()%>
</td>--%>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
<tr>
<td style="padding-top: 2em">
<asp:Button OnClientClick="return isSelectAll(this.value)" ID="btnDelete" runat="server"
CssClass="minbtn" CommandArgument="false" Text="删除" OnClick="btnDelete_Click" />
</td>
</tr>
</table>
</form>
</body>
</html>
C#代码:
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using Model; using System.Text.RegularExpressions; using System.Web.UI.HtmlControls; public partial class manager_ResourceLibrary_HtmlSources : System.Web.UI.Page { private static List<Model.FileAttribute> fileList = new List<FileAttribute>(10); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string path = Request.PhysicalApplicationPath; //if (Request.QueryString["path"] != null && Request.QueryString["path"] != "") //{ // path = path + @"/" + Server.UrlDecode(Request.QueryString["path"]); //} if (Directory.Exists(path)) { string[] strs = Directory.GetFiles(path);//获得路径下的所有文件名 for (int i = 0; i < strs.Length; i++) { Model.FileAttribute fileAttribute = new FileAttribute(); FileInfo fi = new FileInfo(strs[i]); fileAttribute.FileSize = Convert.ToInt32(fi.Length); //fileAttribute.UpdateDate = fi.; fileAttribute.CreateDate = fi.CreationTime; fileAttribute.FileName = fi.Name; fileAttribute.FilePath = fi.FullName; if (new Regex(@".+\.html").IsMatch(fileAttribute.FileName) && File.Exists(fi.FullName)) { fileList.Add(fileAttribute); } } //fileList.Sort(); this.rptPhoto.DataSource = fileList; this.rptPhoto.DataBind(); } } } }
效果图: