private void page_load(object sender, system.eventargs e)
{
string [email protected]"目录绝对路径";
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++)
foreach (directoryinfo dirinfo in subdirectories)
{
response.write("深度="+nlevel+"<br>");
response.write("文件夹:"+dirinfo.name+"/r/n<br>");
fileinfo[] fileinfo =dirinfo.getfiles(); //目录下的文件
//fileinfo[] fileinfo=dirinfo.getfiles("*.dwt");//获取指定类型的文件
foreach (fileinfo finfo in fileinfo)
{
response.write("文件="+finfo.name.tostring()+"/r/n/n");
}
listtreeshow(dirinfo,nlevel+1);
}
}
新闻热点
疑难解答
图片精选