C#asp.net 读取文件夹 列表信息(读取模板目录)ListBox1+Repeater

C#asp.net_读取文件夹_列表信息(读取模板目录)ListBox1+Repeater


后台代码:



        DirectoryInfo folder = new DirectoryInfo(Server.MapPath("~/moban/"));

        foreach (FileInfo file in folder.GetFiles("*.*"))
        {


            ListBox1.Items.Add(file.Name + "|" + file.Length + "|" + file.CreationTime + "|" + file.LastWriteTime + "|" + file.Extension );


        }



        try
        {

            DataTable table = new DataTable();
            table.Columns.Add("Text");
            table.Columns.Add("Value");
            table.Columns.Add("time");
            table.Columns.Add("xiugaitime");
            table.Columns.Add("扩展名");


            for (int i = 0; i < ListBox1.Items.Count; i++)
            {
                DataRow row = table.NewRow();
                row["Text"] = ListBox1.Items[i].Text.Split('|')[0];
                row["Value"] = ListBox1.Items[i].Value.Split('|')[1];
                row["time"] = ListBox1.Items[i].Value.Split('|')[2];
                row["xiugaitime"] = ListBox1.Items[i].Value.Split('|')[3];
                row["扩展名"] = ListBox1.Items[i].Value.Split('|')[4];
                table.Rows.Add(row);
            }
            Repeater1.DataSource = table;
            Repeater1.DataBind();


        }
        catch
        {
        }





前台代码:


    <table class="table table-border table-s1" style="border-spacing: 0px; border-collapse: collapse; width: 1200px; border-left: 1px solid rgb(230, 230, 230); border-right: 1px solid rgb(230, 230, 230); color: rgb(34, 34, 34); font-family: &quot;Microsoft YaHei&quot;, PingFangSC-Light, &quot;PingFang SC&quot;, SimSun, Arial; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
<thead>
<tr class="thead active">
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
文件名</td>
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
类型</td>
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
文件大小</td>
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
创建时间</td>
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
修改时间</td>
<td style="white-space: nowrap; color: rgb(136, 136, 136); text-align: center; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; background: rgb(250, 250, 250)">
操作</td>

</tr>
</thead>
<tbody id="webpage_keywords">




        <asp:Repeater ID="Repeater1" runat="server" >  
        <ItemTemplate>
   
<tr class>
<td style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">
<%#Eval("Text") %> </td>

<td style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">
<%#Eval("扩展名")%></td>

<td style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">
<%#Eval("Value")%></td>

<td style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">
<span class="gray" style="color: rgb(153, 153, 153);"> <%#Eval("time")%></span></td>

<td style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">
<span class="gray" style="color: rgb(153, 153, 153);"> <%#Eval("xiugaitime")%></span></td>

<td id="keywords_postion_1" style="margin: 0px; padding: 10px 0px; border-top: 1px solid rgb(230, 230, 230); border-bottom: 1px solid rgb(230, 230, 230); text-align: center;">

<a style="text-decoration: none; color: rgb(42, 160, 234); padding: 0px 2px;" href="javascript:getKeywordPosition('/ajaxAction/getkeywordposition6.php?domain=www.caotu66.com&amp;wd=%E8%8D%89%E5%9B%BE%E5%A4%A7%E5%B8%88%E6%A8%A1%E5%9E%8B&amp;zs=247&amp;id=1&amp;t=1613289300&amp;token=232c0d1b2e3fe6b98fc86450142c4082',1,'www.caotu66.com','%E8%8D%89%E5%9B%BE%E5%A4%A7%E5%B8%88%E6%A8%A1%E5%9E%8B');">
进入修改</a></td>

</tr>


            </ItemTemplate>   
    </asp:Repeater>







    <asp:ListBox ID="ListBox1" runat="server" Height="100" Width="100" style="display:none">

    </asp:ListBox>





webform
桂ICP备16004754号