Home > Article > Backend Development > asp.net gets the name of the subdirectory under the site root directory
Use Visual Studio to create an .aspx file (Web Forms), such as hovertree.aspx, and add a ListBox to the page
The code is as follows:
Html code
Then the code to display the root directory subfolder on the page is as follows:
C# code
string[] m_subKeleyiFolder = Directory.GetDirectories(Server.MapPath("/hvtimg\"));
int m_countHovertree = m_subKeleyiFolder.Length;
for (int i = 0; i < m_countHovertree; i++)
{
m_subKeleyiFolder[i] = m_subKeleyiFolder[i].S ubstring(m_subKeleyiFolder[i].LastIndexOf(" \") + 1);
}
lbKeleyiFolder.DataSource = m_subKeleyiFolder;
lbKeleyiFolder.DataBind();