zoukankan      html  css  js  c++  java
  • Asp.net遍历ini配置文件节点下所有key和value

    asp.net遍历配置文件某一节点中所有key,value并且绑定到

    Helper app_Helper = new Helper();

    DataSet ds = new DataSet();

    DataTable dt = new DataTable();
       
    protected void Page_Load(object sender, EventArgs e)
    {
        gvwBind();
    }

    #region 绑定GridView

    /// <summary>
    /// 绑定GridView
    /// </summary>
    protected void gvwBind()
    {
        INI.INIPath iniINIPath = new INI.INIPath();
            INI.INIFile iniINIFile = new INI.INIFile(iniINIPath.getINIPath());

        string FolderNames = app_Helper.GetAllFolder(Server.MapPath("http://www.cnblogs.com/APPDIR"));//获得APPDIR文件夹下所有子文件夹名

        string[] FolderName = new string[FolderNames.Split(',').Length - 1];//声明个数组为了保存文件夹绝对路径

        FolderName = FolderNames.Split(',');//给文件夹绝对路径数组赋值

        dt.Columns.Add("LKNAME", typeof(string));
        dt.Columns.Add("qdjsjm", typeof(string));
        dt.Columns.Add("qdipdz", typeof(string));

        for (int i = 0; i < FolderName.Length - 1; i++)
        {
            DataRow row = dt.NewRow();

            FolderName[i] = FolderName[i].Substring(FolderName[i].LastIndexOf('\\') + 1);//截取文件夹名

            row["LKNAME"] = FolderName[i];//给 LKNAME 字符赋值

            if (!iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Equals(""))//配置文件中是否存在相同文件夹名的key
            {
                row["qdjsjm"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[0];//给qdjsjm字段赋值
                row["qdipdz"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[1];//给qdipdz字段赋值
            }

            dt.Rows.Add(row);
        }

        gvwGKWH.DataSource = dt;//绑定到数组
        gvwGKWH.DataBind();风之境地 java-javascript 蘑菇街女装
    }

    #endregion 绑定GridView

  • 相关阅读:
    用Springboot写一个只有一个条件的复杂查询
    Springboot The requested profile "pom.xml" could not be activated because it doesn't not exists
    springboot配置路径
    vuex
    @MappedSuperclass的作用
    icon.css
    default.html
    WebService调用
    通用分页存储过程
    存储过程获得最新订单号
  • 原文地址:https://www.cnblogs.com/sky7034/p/2006391.html
Copyright © 2011-2022 走看看