- ·上一篇文章:数据库中的记录输出来,每行5个
- ·下一篇文章:fso获取文件属性代码
利用fso显示文件夹中的内容
利用fso显示文件夹中的内容,包括子文件夹和文件名
<
HTML>
<
HEAD>
<
TITLE>
fso显示文件夹内容(子目录和文件)<
/TITLE>
<
/HEAD>
<
style>
body 
{font-size:12px
margin-top:20px
margin-left:20px
}
<
/style>
<
BODY>
<
%
&
#39
创建一个FileSystemObject对象的事例
Set 
MyFileObject=Server.CreateObject("
Scripting.FileSystemObject"
)
&
#39
创建一个Folder对象
foldername=server.mappath("
./"
)
Set 
MyFolder=MyFileObject.GetFolder(foldername)
i=0
&
#39
循环显示其中文件夹
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>
显示文件名"
&
#39
循环显示其中文件
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>
<
HTML>
<
HEAD>
<
TITLE>
fso显示文件夹内容(子目录和文件)<
/TITLE>
<
/HEAD>
<
style>
body 
{font-size:12px
margin-top:20px
margin-left:20px
}
<
/style>
<
BODY>
<
%
&
#39
创建一个FileSystemObject对象的事例
Set 
MyFileObject=Server.CreateObject("
Scripting.FileSystemObject"
)
&
#39
创建一个Folder对象
foldername=server.mappath("
./"
)
Set 
MyFolder=MyFileObject.GetFolder(foldername)
i=0
&
#39
循环显示其中文件夹
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>
显示文件名"
&
#39
循环显示其中文件
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>
利用fso显示文件夹中的内容