递归查找一文件夹中是否有asp文件,出现内存不够提示?
dim StrFolder
dim result
StrFolder=request("folder")
result=CheckFileSecurity(StrFolder)
if len(result)>0 then
response.write result
else
response.write "<script language=javascript>alert('该文件夹无危险文件');window.history.back(-1);</script>"
end if
Function CheckFileSecurity(StrFolder)
dim fs,fd,sfd,f
dim whatever
dim strfmt
dim badFile
set fs=server.createObject("Scripting.FileSystemObject")
CheckFileSecurity=true
set fd=fs.getfolder(server.MapPath("/demo/" &StrFolder))
set f=fd.files
for each whatever in f
strfmt=GetFileFmt(cstr(whatever.Name))
if strfmt="asp" then
badFile=badFile & whatever.Name
end if
next
set sfd=fd.subfolders
for each whatever in sfd
'call CheckFileSecurity(whatever.name) '加上这一句就出错
next
set fs=nothing
CheckFileSecurity=badFile
end Function
'得到文件扩展名
function GetFileFmt(StrFile)
dim TmpStr
dim Length
dim t
StrFile=lcase(StrFile)
Length=len(StrFile)
do while length>0
TmpStr=mid(StrFile,Length,1)
if TmpStr="." then
GetFileFmt=right(StrFile,t)
exit do
else
Length=Length-1
t=t+1
end if
loop
end function
我要查找的文件夹里可能有子文件夹,子文件夹里还有可能有子文件夹,要全部检查这些文件夹里是否有asp文件。但加上call CheckFileSecurity(whatever.name) 这一句就出错,不加的话实际上之检查到第一级文件,该怎么办?