asp.net遍歷文件夾下所有子文件夾并綁定到gridview上的方法
更新時(shí)間:2014年08月19日 16:58:27 投稿:whsnow
這篇文章主要介紹了asp.net遍歷文件夾下所有子文件夾并且遍歷配置文件某一節(jié)點(diǎn)中所有key,value并且綁定到GridView上,需要的朋友可以參考下
遍歷文件夾下所有子文件夾,并且遍歷配置文件某一節(jié)點(diǎn)中所有key,value并且綁定到GridView上
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("../../APPDIR"));//獲得APPDIR文件夾下所有子文件夾名 string[] FolderName = new string[FolderNames.Split(',').Length - 1];//聲明個(gè)數(shù)組為了保存文件夾絕對(duì)路徑 FolderName = FolderNames.Split(',');//給文件夾絕對(duì)路徑數(shù)組賦值 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;//綁定到數(shù)組 gvwGKWH.DataBind(); } #endregion 綁定GridView
您可能感興趣的文章:
- asp.net中GridView控件遍歷的小例子
- asp.net datalist 用法
- asp.net Datalist控件實(shí)現(xiàn)分頁(yè)功能
- asp.net DataList與Repeater用法區(qū)別
- asp.net使用for循環(huán)實(shí)現(xiàn)Datalist的分列顯示功能
- ASP.NET MVC使用EasyUI的datagrid多選提交保存教程
- 在asp.net中實(shí)現(xiàn)datagrid checkbox 全選的方法
- asp.net DataGridView導(dǎo)出到Excel的三個(gè)方法[親測(cè)]
- asp.net DataGrid 中文字符排序的實(shí)現(xiàn)代碼
- ASP.NET中GridView、DataList、DataGrid三個(gè)數(shù)據(jù)控件foreach遍歷用法示例
相關(guān)文章
asp.net+jquery ajax無(wú)刷新登錄的實(shí)現(xiàn)方法
asp.net+jquery ajax無(wú)刷新登錄的實(shí)現(xiàn)方法,需要的朋友可以參考一下2013-06-06URL中去除指定參數(shù)實(shí)現(xiàn)C#代碼
URL中去除指定參數(shù)在項(xiàng)目開發(fā)中還是很常見的,本文將介紹下它在c#代碼中的實(shí)現(xiàn),感興趣的朋友可以參考下哈2013-04-04.NET?core項(xiàng)目AsyncLocal在鏈路追蹤中的應(yīng)用
這篇文章主要為大家介紹了.NET?core項(xiàng)目zhong?AsyncLocal在鏈路追蹤中的應(yīng)用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05ASP.NET 5中使用AzureAD實(shí)現(xiàn)單點(diǎn)登錄
本文給大家介紹的是在ASP.NET 5中使用AzureAD實(shí)現(xiàn)單點(diǎn)登錄的方法和示例,有需要的小伙伴可以參考下。2015-07-07asp.net 讀取文本文件并插入數(shù)據(jù)庫(kù)的實(shí)現(xiàn)代碼
最近我司和招行有合作,招行給財(cái)務(wù)的是一個(gè)txt格式的賬務(wù)文本文件,文本文件包含很多內(nèi)容,對(duì)賬只需要用到其中一部分內(nèi)容。2010-04-04asp.net微信開發(fā)(已關(guān)注用戶管理)
這篇文章主要介紹了asp.net微信開發(fā)中有關(guān)已關(guān)注用戶管理的相關(guān)內(nèi)容,需要的朋友可以參考下2015-11-11