风格选择:黄绿 | 天蓝 | 红灰
导航
SEO首页>>网站建设>>程序开发>>ASP中读取某个目录下的文件
ASP中读取某个目录下的文件

 function     bianli(path)         
     
set     fso=createobject("scripting.filesystemobject"
)     
     
on     error     resume     next         
     set     objFolder
=fso.GetFolder(path
)     
     
     
set     objSubFolders=objFolder.
Subfolders         
     
for     
each     objSubFolder     in     objSubFolders         
     
if     right(path,1)<>
"\"     then     
             nowpath=path     +     ""     +     objSubFolder.name         
     else     
             nowpath=path         +     objSubFolder.name         
     end     if     
     Response.Write     nowpath         
     set     objFiles=objSubFolder.Files         
     for     each     objFile     in     objFiles         
     Response.Write     "
<br>
"         
     Response.Write     objFile.name         
     next         
     Response.Write     "
<hr>
"         
             if     objSubFolder.attributes<>16     then     bianli(nowpath)         
     'bianli(nowpath)     
     next         
     Response.Write     path1     
     for     each     objFile1     in     objFolder.Files     
     Response.Write     "
<br>
"         
     Response.Write     objFile1.name         
     next         
     Response.Write     "
<hr>
"         
     set     objFolder=nothing         
     set     objSubFolders=nothing         
     set     fso=nothing     
     end     function
    bianli("
D:myweb")

------------------------------

Dim objFSO,objFolder,objFile,FF '声明 objFSO 变量存放对象实例 
FF = Server.MapPath("./images") 
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 
If objFSO.FolderExists(ff) Then 
Response.write "文件夹 "&ff&" 里所有的文件:<br>" 
Set objFolder = objFSO.GetFolder(ff) 
For Each objFile in objFolder.Files 
Response.Write objFile.Name & "<br>" 
Next 
Else 
Response.Write "文件夹"&ff&"不存在,无法读取相关信息!" 
End If 
Set objFolder = Nothing 
Set objFSO = Nothing '
释放 FileSystemObject 对象实例内存空间

内容来源:EX工作室-SEO资料站
浏览次数:0
ex 发布于 2008-1-26
评论内容
签写评论
你的姓名:
评论主题:
支持UBB: 粗体 斜体 下划线 居中 超级连接 Email连接 插入图片 关闭上传图片 Flash图片 realplay视频文件 Media Player视频文件 飞行字 移动字 发光字
评论内容:
验 证 码:   看不清楚请点击换图
 
会员登陆
用户名  
密    码  
验证码      5200
登陆  |  注册会员
验证码无法显示,请下载修复!

广告推荐
CopyRight © 2007 一厢工作室旗下网站→EX工作室SEO资料站
版权所有 多放合作    E-mail:czx1372@163.com    交流群:23115093 粤ICP备06022088号