小叶白龙

本站整理  发表于:2010-03-11 13:21:13, 分类:技术文章

添加到网摘:

 fso读取文件夹和文件名

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:盘
%>



正在读取日志的评论数据,请稍后……
正在加载日志评论签写框,请稍后……
成员登录通道
正在载入成员登录通道...
BLOG 日历助手
正在载入日历助手...
BLOG 日志归档
BLOG 最新评论
{$SideComment}
BLOG 最新留言
{$SideGB}
BLOG 站内搜索

BLOG 友情链接