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>");
        }
    }
}

 

posted @ 2016-07-15 16:31  WebApi  阅读(8156)  评论(0编辑  收藏  举报
CopyRight © 博客园 WebAPI