using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class admin_tupian_select : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //创建一个DATATABLE用来存储文件数据
            DataTable dt = new DataTable();
            DataColumn dc = new DataColumn();
            dc.ColumnName = "file";
            dt.Columns.Add(dc);
            DataColumn dc1 = new DataColumn();
            dc1.ColumnName = "intro";
            dt.Columns.Add(dc1);

            string temp = "upload";
            if (Request.QueryString["temp"] != null)
            {
                temp = Request.QueryString["temp"].ToString();
            }
            //首先获取文件夹

            DirectoryInfo info = new DirectoryInfo(Server.MapPath("../" + temp));

            DirectoryInfo[] dir = info.GetDirectories();

            foreach (DirectoryInfo d in dir)
            {
                // Label1.Text = Label1.Text +">"+ d.Name;
                DataRow row = dt.NewRow();
                row["file"] = "<img src='skin/fold.gif' /><a href='tupian_select.aspx?temp=" + temp + "/" + d.Name + "' >" + d.Name + "</a>";
                dt.Rows.Add(row);

               
            }
            //导航
            Label1.Text = temp;
            
            //获取所有文件
            FileInfo[] files = info.GetFiles();

            foreach (FileInfo file in files)
            {
                if (file.Name.ToLower().Contains(".bmp") || file.Name.ToLower().Contains(".jpg") || file.Name.ToLower().Contains(".jpeg") || file.Name.ToLower().Contains(".gif")||file.Name.ToLower().Contains(".png"))
                {

                    DataRow row = dt.NewRow();
                    row["file"] = "<img src='skin/image.gif' /><a href='#' onclick=ok('/" + temp + "/" + file.Name + "') >" + file.Name + "</a>";

                  
                    dt.Rows.Add(row);
                }
            }
            Repeater1.DataSource = dt;
            Repeater1.DataBind();
        }
    }
}
