ASP遍历文件问题
<%functionbianli(path)dimfsodimobjFolderdimobjSubFoldersdimobjSubFolderdimobjFilesdim...
<%
function bianli(path)
dim fso
dim objFolder
dim objSubFolders
dim objSubFolder
dim objFiles
dim objFile
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 nowpath+ "\\" + objFile.name
next
Response.Write "<p>"
bianli(nowpath)
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
bianli("D:\shuaigua\56bohai")
%>
为何不能显示D:\shuaigua\56bohai文件夹下的文件。。只显示子文件夹下的??? 展开
function bianli(path)
dim fso
dim objFolder
dim objSubFolders
dim objSubFolder
dim objFiles
dim objFile
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 nowpath+ "\\" + objFile.name
next
Response.Write "<p>"
bianli(nowpath)
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
bianli("D:\shuaigua\56bohai")
%>
为何不能显示D:\shuaigua\56bohai文件夹下的文件。。只显示子文件夹下的??? 展开
1个回答
展开全部
<%
sub bianli(path)
dim fso
dim objFolder
dim objSubFolder
dim objFile
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
for each objFile in objFolder.Files
Response.Write path & "\\" & objFile.name & "<br>---"
next
Response.Write "<p>"
for each objSubFolder in objFolder.Subfolders
nowpath=path & "\\" & objSubFolder.name
Response.Write nowpath & "<br>"
bianli nowpath
next
set objFolder=nothing
set fso=nothing
end sub
bianli "D:\shuaigua\56bohai"
%>
看明白没有?你要先显示当前文件夹(注意当前)中的文件集合,再遍历文件夹中的子文件夹集合。而你的做法则是显示子文件夹(注意子字)中的文件集合,再去遍历子文件夹集合,这样的话一开始的那个文件夹(即D:\shuaigua\56bohai)的文件就无法显示了!
sub bianli(path)
dim fso
dim objFolder
dim objSubFolder
dim objFile
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
for each objFile in objFolder.Files
Response.Write path & "\\" & objFile.name & "<br>---"
next
Response.Write "<p>"
for each objSubFolder in objFolder.Subfolders
nowpath=path & "\\" & objSubFolder.name
Response.Write nowpath & "<br>"
bianli nowpath
next
set objFolder=nothing
set fso=nothing
end sub
bianli "D:\shuaigua\56bohai"
%>
看明白没有?你要先显示当前文件夹(注意当前)中的文件集合,再遍历文件夹中的子文件夹集合。而你的做法则是显示子文件夹(注意子字)中的文件集合,再去遍历子文件夹集合,这样的话一开始的那个文件夹(即D:\shuaigua\56bohai)的文件就无法显示了!
追问
ASP我不是很懂啊。。。大神请问怎么改?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询