asp.net获取站点根目录下子目录的名称

使用Visual Studio建立一个.aspx文件(Web Forms),例如hovertree.aspx,在页面上加入一个ListBox
代码如下:

Html代码  收藏代码
  1. <asp:ListBox runat="server" ID="lbKeleyiFolder" />  

 

那么在页面上显示根目录子文件夹的代码如下:

C#代码  收藏代码
  1. string[] m_subKeleyiFolder = Directory.GetDirectories(Server.MapPath("/hvtimg\"));  
  2.   
  3. int m_countHovertree = m_subKeleyiFolder.Length;  
  4. for (int i = 0; i < m_countHovertree; i++)  
  5. {  
  6. m_subKeleyiFolder[i] = m_subKeleyiFolder[i].Substring(m_subKeleyiFolder[i].LastIndexOf("\") + 1);  
  7. }  
  8.   
  9. lbKeleyiFolder.DataSource = m_subKeleyiFolder;  
  10. lbKeleyiFolder.DataBind();  

 

HoverTree系统源码下载http://hovertree.codeplex.com/

原文地址:https://www.cnblogs.com/ranran/p/4499334.html