zoukankan      html  css  js  c++  java
  • 列出文件夹下文件列表,显示,删除

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

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    enumerate()
    列表
    pycharm下getpass.getpass()卡住
    字符编码
    while_else
    guess_age
    数据类型
    python发展史
    吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:JSP的基本原理
    吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:Web应用和web.xml文件
  • 原文地址:https://www.cnblogs.com/houweidong/p/3439109.html
Copyright © 2011-2022 走看看