Asp.net traverses all subfolders in the folder and binds them to the gridview. asp. netgridview

Source: Internet
Author: User

Asp.net traverses all subfolders in the folder and binds them to the gridview. asp. netgridview

Traverse all subfolders in the folder, traverse all keys and values in a node of the configuration file, and bind 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.GetAll Folder (Server. mapPath (".. /.. /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 dt to the absolute path array of the folder. 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 an 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 row ["qdipdz"] = iniINIFile to the qdjsjm field. iniReadValue ("dzjclkzp", FolderName [I]). split (',') [1]; // assign a value to the qdipdz field} dt. rows. add (row);} gvwGKWH. dataSource = dt; // bind it to the array gvwGKWH. dataBind () ;}# endregion binds the GridView



Hurry up, aspnet C # traverse the files in the folder and bind the file name to the GridView. How can I write the download path to download these files?

Just output the files on the server to the client as a stream.

Aspnet (c #) traverses a folder with TreeView. How can I click a node to open the file?

Now that you have traversed the folder
Add it cyclically in the selectedChanged event
System. Diagnostics. Process. Start ("f: \ a.txt ");
Next, just traverse it again and try again. Wish you success.

Related Article

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.