遍历文件夹下所有子文件夹,并且遍历配置文件某一节点中所有key,value并且绑定到GridView上
C#代码
class="star" src="/Upload/Images/2014081415/40B102E0EF997EA6.png" alt="收藏代码" />
- Helper app_Helper = new Helper();
-
- DataSet ds = new DataSet();
-
- DataTable dt = new DataTable();
-
- protected void Page_Load(object sender, EventArgs e)
- {
- gvwBind();
- }
-
- #region 绑定GridView
-
- protected void gvwBind()
- {
- INI.INIPath iniINIPath = new INI.INIPath();
- INI.INIFile iniINIFile = new INI.INIFile(iniINIPath.getINIPath());
-
- string FolderNames = app_Helper.GetAllFolder(Server.MapPath("../../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];
-
- if (!iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Equals(""))
- {
- row["qdjsjm"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[0];
- row["qdipdz"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[1];
- }
-
- dt.Rows.Add(row);
- }
-
- gvwGKWH.DataSource = dt;
- gvwGKWH.DataBind();
- }
-
- #endregion 绑定GridView
推荐篇文章