前两天有人问怎么取得一个目录下的文件,下面就是例子

发表于:2007-06-30来源:作者:点击数: 标签:
%@ Language= VB Script % % ‘’================================================================ ‘’函数名称:FileList ‘’函数功能:列出目录下所有文件 ‘’主要参数说明: ‘’1——FolderUrl虚拟路径不可为空 ‘’2----FileExName文件扩展名 ‘’
<%@ 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")
%>

原文转自:http://www.ltesting.net