zoukankan      html  css  js  c++  java
  • 对文件夹进行操作浏览器中的文件列表

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;

    public partial class _Default : System.Web.UI.Page 
    {
        
    protected void Page_Load(object sender, EventArgs e)
        {
            
    string strCurrentDir;
            strCurrentDir 
    = Server.MapPath(".");
            lblCurrentDir.Text 
    = strCurrentDir;

            FileInfo fi;
            DirectoryInfo di;
            TableCell td;
            TableRow tr;

            
    string FileName;
            
    string FileExt;
            
    long FileSize;
            DateTime FileModify;
            DirectoryInfo dir 
    = new DirectoryInfo(strCurrentDir);
            
    foreach (FileSystemInfo fsi in dir.GetFileSystemInfos())
            {
                FileName 
    = "";
                FileExt 
    = "";
                FileSize 
    = 0;
                
    if (fsi is FileInfo)
                {
                    fi 
    = (FileInfo)fsi;
                    FileName 
    = fi.Name;
                    FileExt 
    = fi.Extension;
                    FileSize 
    = fi.Length;
                    FileModify 
    = fi.LastWriteTime;
                }
                
    else
                {
                    di 
    = (DirectoryInfo)fsi;
                    FileName 
    = di.Name;
                    FileModify 
    = di.LastWriteTime;
                }
                tr 
    = new TableRow();
                td 
    = new TableCell();
                td.Controls.Add(
    new LiteralControl(FileName.ToString()));
                tr.Cells.Add(td);
                td 
    = new TableCell();
                td.Controls.Add(
    new LiteralControl(FileSize.ToString()));
                tr.Cells.Add(td);
                td 
    = new TableCell();
                td.Controls.Add(
    new LiteralControl(FileModify.ToString()));
                tr.Cells.Add(td);
                tbDirInfo.Rows.Add(tr);
            }
        }
    }

        <form id="form1" runat="server">
        
    <div>
            当前目录为:
    <asp:Label ID="lblCurrentDir" runat="server"></asp:Label><br />
            目录下文件的列表为:
    <br />
            
    <asp:Table ID="tbDirInfo" runat="server">
            
    </asp:Table>
        
    </div>
        
    </form>
  • 相关阅读:
    绿盟UTS综合威胁探针管理员任意登录
    深信服EDR3.2.21任意代码执行
    linux反弹shell总结
    mysql在8.0版本下修改密码的命令
    Linux提权常用漏洞速查表
    windows提权常用系统漏洞与补丁编号速查对照表
    通达OA<=11.5版本SQL注入——附件上传
    通达OA<=11.5版本SQL注入——日程安排
    希尔伯特曲线python3实现
    深信服edr控制中心漏洞——验证码逻辑错误
  • 原文地址:https://www.cnblogs.com/qixin622/p/753293.html
Copyright © 2011-2022 走看看