asp.net io类递归显示目录信息
.aspx.cs代码
private void page_load(object sender, system.eventargs e)
{
// 在此处放置用户代码以初始化页面
string strdirlist=request.querystring.get("dir");
directoryinfo thisone=new directoryinfo(strdirlist);
response.write("<pre>");
listtreeshow(thisone,0);
response.write("</pre>");
}
private void listtreeshow(directoryinfo thedir,int nlevel){
directoryinfo[] subdirectories=thedir.getdirectories();
for(int i=0;i<subdirectories.length;i++){
response.write(nlevel);
response.write(subdirectories[i].name+"/r/n");
listtreeshow(subdirectories[i],nlevel+1);
}
}
新闻热点
疑难解答
图片精选