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>
  • 相关阅读:
    如何找出阻塞的线程正在等待哪个线程
    探索Windows 10的CFG机制
    异常0xc000041d的抛出过程
    异常STATUS_FATAL_USER_CALLBACK_EXCEPTION(0xc000041d)
    VisualStudio中集成扩展调试SOS
    clr调试扩展和DAC
    WinDbg常用命令系列---sx, sxd, sxe, sxi, sxn, sxr, sx- (设置异常)
    CLR调试时的sos.dll/clr.dll/mscorwks.dll/mscordacwks.dll等动态库的版本对应
    WinDbg常用命令系列---!runaway
    WinDbg常用命令系列---!findstack
  • 原文地址:https://www.cnblogs.com/qixin622/p/753293.html
Copyright © 2011-2022 走看看