Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string filetype = "bak";
            if (!string.IsNullOrEmpty(Request.QueryString["filetype"]))
            {
                filetype = Request.QueryString["filetype"];
            }

            string root = "~/backup";
            if (!string.IsNullOrEmpty(Request.QueryString["path"]))
            {
                root += Request.QueryString["path"];
            }
            string path = Server.MapPath(root);

            DirectoryInfo dir = new DirectoryInfo(path);
            List <Dukey.Model.Fileinfo> list = new List <Dukey.Model.Fileinfo>();

            foreach (var item in dir.GetDirectories())
            {
                Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                model.filetype   = "folder";
                model.filename   = item.Name;
                model.filesize   = (getSize(item.FullName) / 1024).ToString() + " K";
                model.updatetime = item.LastWriteTime.ToString();

                list.Add(model);
            }

            foreach (var item in dir.GetFiles())
            {
                Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                model.filetype   = item.Extension.Replace(".", "");
                model.filename   = item.Name;
                model.filesize   = (item.Length / 1024).ToString() + " K";
                model.updatetime = item.LastWriteTime.ToString();

                if (filetype.Contains(model.filetype.ToLower()))
                {
                    list.Add(model);
                }
            }

            gvList.DataSource = list;
            gvList.DataBind();

            if (dal.ToLower() == "SQLServerDAL".ToLower())//sqlserver数据库
            {
                btnCompress.Visible = false;
            }
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string root = "~/template";
            if (!string.IsNullOrEmpty(Request.QueryString["path"]))
            {
                root += Request.QueryString["path"];
            }
            string path = Server.MapPath(root);

            DirectoryInfo dir = new DirectoryInfo(path);
            List <Dukey.Model.Fileinfo> list = new List <Dukey.Model.Fileinfo>();

            foreach (var item in dir.GetDirectories())
            {
                if (!item.Attributes.ToString().Contains("Hidden"))
                {
                    Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                    model.filetype   = "folder";
                    model.filename   = item.Name;
                    model.filesize   = (getSize(item.FullName) / 1024).ToString() + " K";
                    model.updatetime = item.LastWriteTime.ToString();
                    list.Add(model);
                }
            }

            foreach (var item in dir.GetFiles())
            {
                if (!item.Attributes.ToString().Contains("Hidden"))
                {
                    Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                    model.filetype   = item.Extension.Replace(".", "");
                    model.filename   = item.Name;
                    model.filesize   = (item.Length / 1024).ToString() + " K";
                    model.updatetime = item.LastWriteTime.ToString();
                    list.Add(model);
                }
            }

            gvList.DataSource = list;
            gvList.DataBind();
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string root = "~/template";
            if (!string.IsNullOrEmpty(Request.QueryString["path"]))
            {
                root += Request.QueryString["path"];

            }
            string path = Server.MapPath(root);

            DirectoryInfo dir = new DirectoryInfo(path);
            List<Dukey.Model.Fileinfo> list = new List<Dukey.Model.Fileinfo>();

            foreach (var item in dir.GetDirectories())
            {
                if (!item.Attributes.ToString().Contains("Hidden"))
                {
                    Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                    model.filetype = "folder";
                    model.filename = item.Name;
                    model.filesize = (getSize(item.FullName) / 1024).ToString() + " K";
                    model.updatetime = item.LastWriteTime.ToString();
                    list.Add(model);
                }
            }

            foreach (var item in dir.GetFiles())
            {
                if (!item.Attributes.ToString().Contains("Hidden"))
                {
                    Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                    model.filetype = item.Extension.Replace(".", "");
                    model.filename = item.Name;
                    model.filesize = (item.Length / 1024).ToString() + " K";
                    model.updatetime = item.LastWriteTime.ToString();
                    list.Add(model);
                }
            }

            gvList.DataSource = list;
            gvList.DataBind();

        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string filetype = "bak";
            if (!string.IsNullOrEmpty(Request.QueryString["filetype"]))
            {
                filetype = Request.QueryString["filetype"];
            }

            string root = "~/backup";
            if (!string.IsNullOrEmpty(Request.QueryString["path"]))
            {
                root += Request.QueryString["path"];

            }
            string path = Server.MapPath(root);

            DirectoryInfo dir = new DirectoryInfo(path);
            List<Dukey.Model.Fileinfo> list = new List<Dukey.Model.Fileinfo>();

            foreach (var item in dir.GetDirectories())
            {
                Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                model.filetype = "folder";
                model.filename = item.Name;
                model.filesize = (getSize(item.FullName) / 1024).ToString() + " K";
                model.updatetime = item.LastWriteTime.ToString();

                list.Add(model);

            }

            foreach (var item in dir.GetFiles())
            {
                Dukey.Model.Fileinfo model = new Dukey.Model.Fileinfo();
                model.filetype = item.Extension.Replace(".", "");
                model.filename = item.Name;
                model.filesize = (item.Length / 1024).ToString() + " K";
                model.updatetime = item.LastWriteTime.ToString();

                if (filetype.Contains(model.filetype.ToLower()))
                {
                    list.Add(model);
                }
            }

            gvList.DataSource = list;
            gvList.DataBind();

            if (dal.ToLower() == "SQLServerDAL".ToLower())//sqlserver数据库
            {
                btnCompress.Visible = false;
            }
        }
    }