using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.IO;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Directory.Exists(TextBox1.Text) == false)
        {
            Response.Write("<script>alert('输入的驱动器信息不正确！ ')</script>");
            return;
        }
        else
        {
            DirectoryInfo di = new DirectoryInfo(TextBox1.Text);
            FileSystemInfo[] dis = di.GetFileSystemInfos();
            if (dis.Length >= 1)
            {
                ListBox1.DataSource = dis;
                ListBox1.DataBind();
            }
        }
    }
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session.Clear();
        Session["id"] = TextBox1.Text + "\\" + ListBox1.SelectedValue.ToString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            DirectoryInfo di = new DirectoryInfo(Session["id"].ToString());

            FileSystemInfo[] dis = di.GetFileSystemInfos();

            if (dis.Length >= 1)
            {
                ListBox2.DataSource = dis;
                ListBox2.DataBind();
            }
        }
        catch (Exception error)
        {
            ListBox2.DataSource = "";
            ListBox2.DataBind();
            return;
        }
    }
}
