Asp.net traverses all keys and values under the ini configuration file Node

Source: Internet
Author: User

Asp.net traverses all keys and values in a node of the configuration file and binds them to the gridview.

Helper app_helper = new helper ();

Dataset DS = new dataset ();

Datatable dt = new datatable ();

Protected void page_load (Object sender, eventargs E)
{
Gvwbind ();
}

# Region bind the gridview

/// <Summary>
/// Bind the 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"); // obtain the names of all subfolders in the appdir folder

String [] Foldername = new string [foldernames. Split (','). Length-1]; // declare an array to save the absolute path of the folder

Foldername = foldernames. Split (','); // assign a value to the absolute path array of the folder.

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); // capture the folder name

Row ["lkname"] = Foldername [I]; // assign a value to the lkname character

If (! Iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Equals ("") // check whether the key with the same folder name exists in the configuration file
{
Row ["qdjsjm"] = iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Split (',') [0]; // assign a value to the qdjsjm Field
Row ["qdipdz"] = iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Split (',') [1]; // assign a value to the qdipdz Field
}

DT. Rows. Add (ROW );
}

Gvwgkwh. datasource = DT; // bind to an array
Gvwgkwh. databind (); fashion Java-JavaScript mogujie.com women's clothing
}

# Bind endregion to the gridview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.