日期:2013-02-27  浏览次数:21294 次

<%@ Language=VBScript %>
<%
'================================================================
'函数名称:FileList
'函数功能:列出目录下所有文件
'主要参数说明:
'1——FolderUrl     虚拟路径  不可为空
'2----FileExName    文件扩展名
'函数返回值:收文记录
'================================================================
Function FileList(FolderUrl,FileExName)
    Set fso=Server.CreateObject("Scripting.FileSystemObject")
    Set folder=fso.GetFolder(Server.MapPath(Trim(FolderUrl)))
    Set file=folder.Files
    FileList=""
    For Each FileName in file
        If Trim(FileExName)<>"" Then
            If InStr(Trim(FileExName),Trim(Mid(FileName.Name,InStr(FileName.Name,".")+1,len(FileName.Name))))>0 Then
                FileList=FileList&FileName.Name&"<br>"
            End If
        Else
            FileList=FileList&FileName.Name&"<br>"
        End If
    Next
    Set file=Nothing
    Set folder=Nothing
    Set fso=Nothing
End Function
Response.Write FileList("/你的虚拟路径","gif,GIF,jpg,JPG")
%>