<%
Sub AllFiles(dirPath)
i=0
Randomize
On Error Resume Next
if right(dirPath,1)<>"\" then dirPath=dirPath&"\"
Set FSO = CreateObject("scripting.filesystemobject")
Set f = FSO.GetFolder(dirPath)
Set fs = f.files
dim Str,Arr,a,Content,url,ShowContent
For Each fileN in fs
if
RegExpfind(".html",fileN.name) then
Str=fileN.name
if Rnd>0.6 then
i=i+1
response.write str&"<br>"
end if
end if
if i>4 then exit for
Next
Set FSO = Nothing
End sub
Function RegExpfind(patrn, strng)
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
RegExpfind = regEx.Test(strng)
End Function
AllFiles(server.mappath(""))
%>
以上代码同样没有解决不足五位的情况,思路是把读文件的指针恢复到开头,具体代码想不起来了,实在不行就做个循环把文件名再读一次,再到够5个。