asp.net获取文件夹下的所有文件

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class admin_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string path = Server.MapPath("/ceshi/");
        DirectoryInfo di = new DirectoryInfo(path);
        //找到该目录下的文件 
        FileInfo[] fis = di.GetFiles();
        foreach (FileInfo fi in fis)
        {
            Response.Write(fi.Name);
            Response.Write("<br>");
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/gygtech/p/9910505.html