asp遍历站点所有文件夹的代码

2018-09-06 13:15

阅读:548

  <!--遍历站点所有文件夹-->
<style>
<!--
body{font-size:12px;}
-->
</style>
<scriptlanguage=vbscript>
<!--
subfsubmit()
form1.submit
Endsub
-->
</script>
<formname=form1method=postaction=findfolder.asp>
<selectsize=1name=fpathonchange=fsubmit()>
<optionvalue=0selected>--请选择--</option>
<optionvalue=/>整个站点</option>
<optionvalue=.>当前目录</option>
<%
Dimfso,objfolder,objfile,strpath
setfso=server.createobject(Scripting.FileSystemObject)

strpath=.
callbl(strpath)

functionbl(strpath)
setobjfolder=fso.getfolder(server.mappath(strpath))

foreachobjsubfolderinobjfolder.subfolders
callbl(strpath&\&objsubfolder.name)
next

Endfunction
%>
</select>
</form>

<%
fpath=Request.form(fpath)

iffpath<>0andfpath<>Emptythen

Response.write<fontcolor=#FF0000>当前文件夹:&replace(fpath,.,)&</font><br><br>

setobjfolder=fso.getfolder(server.mappath(fpath))

foreachobjsubfolderinobjfolder.subfolders
Response.write子文件夹名称:&objsubfolder.name&<br>
next

Response.write<br>

foreachobjfileinobjfolder.files
Response.write文件名称:&objfile.name&<br>
next

setobjfolder=nothing

Endif
%>


评论


亲,登录后才可以留言!