1:
<%
‘创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
path=server.mappath("./conn/database/") ‘当前目录下folder文件夹目录
‘创建一个Folder对象
Set MyFolder=MyFileObject.GetFolder(path)
For Each thing in MyFolder.SubFolders ‘获取子文件夹
response.write "<p>目录:"&thing
‘ MyFileObject.DeleteFolder thing 删除文件夹,注意使用
next
‘循环显示其中文件
For Each thing in MyFolder.Files
Response.Write("<p>文件:"&thing) ‘输出文件路径
‘MyFileObject.DeleteFile thing ‘删除这些文件,此删除不可以恢复,需要小心使用
Next
set n=MyFolder.Files
For Each a in n
Response.Write("<br>"&a.name&"")
next
%>
2:
<%
function bianli(path)
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objSubFolders
nowpath=path + "\" + objSubFolder.name
Response.Write nowpath
set objFiles=objSubFolder.Files
for each objFile in objFiles
Response.Write "<br/>—"
Response.Write objFile.name
next
Response.Write "<p>"
bianli(nowpath)”递归
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
bianli("G:") ”遍历G:盘
%>
评论前必须登录!
注册