asp. net method that traverses all subfolders under the folder and binds to gridview
- 2020-12-22 17:37:16
- OfStack
Traverse all subfolders under the folder, and traverse all key,value in a node of the configuration file and bind to GridView
Helper app_Helper = new Helper();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
gvwBind();
}
#region The binding GridView
/// <summary>
/// The binding 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"));// To obtain APPDIR All subfolder names under the folder
string[] FolderName = new string[FolderNames.Split(',').Length - 1];// Declare an array to hold the absolute path to the folder
FolderName = FolderNames.Split(',');// Assign a value to the absolute path array of folders
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);// Intercept folder name
row["LKNAME"] = FolderName[i];// to LKNAME Characters of the assignment
if (!iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Equals(""))// Whether the same folder name exists in the configuration file key
{
row["qdjsjm"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[0];// to qdjsjm Field assignment
row["qdipdz"] = iniINIFile.IniReadValue("dzjclkzp", FolderName[i]).Split(',')[1];// to qdipdz Field assignment
}
dt.Rows.Add(row);
}
gvwGKWH.DataSource = dt;// Bind to an array
gvwGKWH.DataBind();
}
#endregion The binding GridView