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

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

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

利用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>


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