<% 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&"
"
End If
Else
FileList=FileList&FileName.Name&"
"
End If
Next
Set file=Nothing
Set folder=Nothing
Set fso=Nothing
End Function
Response.Write FileList("/你的虚拟路径","gif,GIF,jpg,JPG")
%>
前两天有人问怎么取得一个目录下的文件,下面就是例子
80酷酷网 80kuku.com