当前位置:K88软件开发文章中心编程语言AspAsp01 → 文章内容

asp实现查找指定目录下的某一扩展名的文件

减小字体 增大字体 作者:佚名     来源:asp编程网  发布时间:2018-12-30 8:32:30

实现的原理是使用fso和递归实现查找指定目录下某一扩展名的文件
<
%
'===========================================
' 函数功能:asp实现查找指定目录下的某一扩展名的文件
' 作 
 
 
者:wangsdong
' 网 
 
 
站: http://www.aspprogram.cn
' 参数意义:path为相对路径,当前目录使用“.”,上级目录“..”,

 
 
 
 
 
 
 
 
 
 
 
 
 
 
下级目录直接输入文件夹名,style为扩展名:如asp,mdb等
' 文章为作者支持!
'===========================================
Function findfile(path,style)
'创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
'创建一个Folder对象
foldername=server.mappath(path)
Set MyFolder=MyFileObject.GetFolder(foldername)
'循环显示其中文件夹
For Each thing in MyFolder.subfolders
 
if MyFileObject.folderExists(thing) then 
 
 
 
 
 
 
 
 
 
 
'判断folder文件夹是否存在
 
 
 
 
t2=thing 
 
 

 
 
 
 
 
folder=Replace(thing,foldername&
"\","")
 
 
t=path&
"/"&
folder
 
 
Call findfile(t,style)
 
end if
Next
'循环显示其中文件
For Each thing in MyFolder.Files
 
if MyFileObject.FileExists(thing) then 
 
 
 
 
 
 
 
 
 
 
'判断folder文件夹是否存在
 
 
 
t2=thing
 
m=Split(thing,"\")
 
filename=m(UBound(m))
 
t0=Split(filename,".")(1)
 
If t0=style Then
 
 
response.write thing&
"<
BR>
"
 
End if
 
end if
Next
End Function

Call findfile(".","mdb")
% >



asp实现查找指定目录下的某一扩展名的文件