首页 > 学院 > 开发设计 > 正文

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

2019-11-17 02:05:50
字体:
来源:转载
供稿:网友

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

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

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

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

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

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表