首页 > Web开发 > 详细

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

时间:2015-05-13 10:03:30      阅读:287      评论:0      收藏:0      [点我收藏+]

使用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/

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

原文:http://www.cnblogs.com/ranran/p/4499334.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!