列出文件夹下文件列表,显示,删除
using System.IO; 
using System.Collections;
public partial class _Default : System.Web.UI.Page   
{    
    protected void Page_Load(object sender, EventArgs e)    
    {    
        if (!IsPostBack)    
        {    
            ArrayList arylst = new ArrayList();    
            string filepath = Server.MapPath("list");    
            DirectoryInfo info = new DirectoryInfo(filepath);    
            FileInfo[] fileinfo = info.GetFiles();    
            foreach (FileInfo allfile in fileinfo)    
            {    
                arylst.Add(allfile);    
            }    
            this.ListBox1.DataSource = arylst;    
            this.ListBox1.DataBind();
        }   
    }    
}
 protected void btnView_Click(object sender, EventArgs e)
    {
        Response.Redirect("list/" + this.ListBox1.SelectedValue);
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string filepath = Server.MapPath("list/");
        File.Delete(filepath + this.ListBox1.SelectedValue);
        Response.Write("<script>alert('页面删除成功!');location='Default.aspx'</script>");
    }
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号