Asp.net learning notes (1)

Source: Internet
Author: User

1. display the drive list: // call the static method of directory getlogicaldrives
String [] mydirve = directory. getlogicaldrives;

2. Directory and file list display:
Directory mydir = new directory ();
Directory [] subdir = mydir. getdirectories ();
File [] thisfile = mydir. getfiles ();

3. /// <summary>
/// Used to preview the first 255 characters of a text file
/// </Summary>
Public static string previewfile (string funpath)
{
Streamreader myrd = file. opentext (funpath );
Char [] charbuffer = new char [255];
Int Iread = myrd. readblock (charbuffer, 0,255 );
Return (new string (charbuffer, 0, Iread ));
}

4. ///


/// return the HTML format string of the directory list, used to display the directory list in htlm
///
Public static string getsubdirlist (string strpath, int ilevel)
{< br> string strdirlist_out = "
"; 
string [] strdirs = directory. getdirectories (strpath);
for (INT I = 0; I {< br> strdirlist_out + = new string ('', ilevel * 2);
strdirlist_out + =" | __";
strdirlist_out + = strdirs [I] + "/R/N";
strdirlist_out + = getsubdirlist (strdirs [I], ilevel + 1 );
}< br> strdirlist_out + = "
";
return strdirlist_out;
}

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.