当前位置:asp编程网>技术教程>Asp教程>  正文

利用fso显示文件夹中的内容

2007-12-17 08:23:18   来源:aspprogram.cn    作者:佚名   浏览量:1829   收藏
利用fso显示文件夹中的内容,包括子文件夹和文件名
<HTML>
<HEAD><TITLE>fso显示文件夹内容(子目录和文件)</TITLE></HEAD>
<style>
body {font-size:12px;margin-top:20px;margin-left:20px;}
</style>
<BODY>
<%
'创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
'创建一个Folder对象
foldername=server.mappath("./")
Set MyFolder=MyFileObject.GetFolder(foldername)
i=0
'循环显示其中文件夹
response.write "显示文件夹:"
For Each thing in MyFolder.subfolders
Response.Write("<br>"&#38;thing)
i=i+1
Next
response.write "<br>共有"&#38;i&#38;"个文件夹"

response.write "<p>显示文件名"
'循环显示其中文件
i=0
For Each thing in MyFolder.Files
Response.Write("<br>"&#38;thing)
i=i+1
Next
response.write "<br>共有"&#38;i&#38;"个文件"
%>
</Body>
</HTML>

关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网