62,271
社区成员
发帖
与我相关
我的任务
分享HTML code<%@ Import Namespace="System.IO" %>
<table style="width: 98%; background-color: #e7e3e7;" cellspacing="1" cellpadding="4"
align="center" id="ajaxtable">
<tbody>
<tr align="center" class="head">
<td style="width: 5%;">
操作
</td>
<td width="50%">
文件名
</td>
<td style="width: 30%;">
生成日期
</td>
</tr>
<% foreach (FileInfo f in files) { %>
<tr align="center" class="dinfo" style="background-color: #D8D8D8;">
<td>
<a href="javascript:delF('<%=f.Name %>','delfile',<%=ModelID %>)">删除</a>
</td>
<td>
<a href="/<%=FilePath + "/" + ModelID + "/" + f.Name %>" target="_blank">
<%=f.Name %>
</a>
</td>
<td>
<%=f.LastWriteTime.ToString("yyyy-MM-dd HH:mm") %>
</td>
</tr>
<%} %>
</tbody>
</table>
后台
C# code
protected List<FileInfo> files = new List<FileInfo>();
protected string FilePath = ConfigurationManager.AppSettings["FileDir"];
protected void Page_Load(object sender, EventArgs e) {
if (!Request.IsAuthenticated)
return;
string strTemplatePath = Server.MapPath(string.Format("/{0}", FilePath));
DirectoryInfo dir = new DirectoryInfo(strTemplatePath);
if (dir.Exists) {
files.AddRange(dir.GetFiles("*.xlsx").OrderByDescending(t => t.LastWriteTime));
}
