取得一个目录下的文件
类别: ASP教程
<%@ 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")
%>
<%
\'================================================================
\'函数名称: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")
%>
-= 资 源 教 程 =-
文 章 搜 索