首页  >  文章  >  后端开发  >  asp.net获取站点根目录下子目录的名称

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

巴扎黑
巴扎黑原创
2016-12-19 15:57:222138浏览

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

Html代码  

  

 

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

C#代码  

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].Substring(m_subKeleyiFolder[i].LastIndexOf("\\") + 1);  

}  

  

lbKeleyiFolder.DataSource = m_subKeleyiFolder;  

lbKeleyiFolder.DataBind();  


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn