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 Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            FileManager();
        }
    }
    protected void FileManager()
    {
        int dt = 0;
        string[] dictoryNames ={ "admin", "Bin", "Company", "Control", "css", "Images", "img", "install", "js", "login", "member", "News", "Purchase", "Search", "Shops", "ShopTemplate", "Supply", "Templates", "xml" };
        string[] fileNames ={ "Default.aspx", "Error.aspx", "web.config" };
        string path = HttpContext.Current.Server.MapPath("~/");
        string str = "\n";
        for (int i = 0; i < fileNames.Length; i++)
        {
            FileInfo fi = new FileInfo(path + fileNames[i]);
            if (fi.Exists)
            {
                if ((File.GetAttributes(path + fileNames[i]) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
                {
                    str += "<li><img src=\"images/checked.gif\"> " + fi.Name + "</li>\n";
                }
                else
                {
                    str += "<li><img src=\"images/cancel.gif\"> " + fi.Name + "</li>\n";
                    dt++;
                }
            }
            else
            {
                str += "<li><img src=\"images/cancel.gif\"> " + fi.Name + "</li>\n";
                dt++;
            }
        }
        for (int i = 0; i < dictoryNames.Length; i++)
        {
            DirectoryInfo dir = new DirectoryInfo(path + dictoryNames[i]);
            if (dir.Exists)
            {
                bool bl = IsFile(path + dictoryNames[i]);
                if (bl == true)
                {
                    str += "<li><img src=\"images/checked.gif\"> " + dir.Name + "</li>\n";
                }
                else
                {
                    str += "<li><img src=\"images/cancel.gif\"> " + dir.Name + "</li>\n";
                    dt++;
                }
            }
            else
            {
                str += "<li><img src=\"images/cancel.gif\"> " + dir.Name + "</li>\n";
                dt++;
            }
        }
        lblContext.Text = str;
        if (dt > 0)
        {
            this.btn_next.Enabled = false;
        }
        else
        {
            this.btn_next.Enabled = true;
        }
    }

    protected bool IsFile(string path)
    {
        //检查文件夹的属性
        FileInfo fi = new FileInfo(path + "/temp.txt");
        try
        {
            if (!fi.Exists)
            {
                FileStream fis = fi.Create();
                fis.Close();
            }
            fi.Delete();
            return true;
        }
        catch
        {
            return false;
        }
    }
}