- ·上一篇文章:asp中将字符转换成变量使用
- ·下一篇文章:asp利用dictionary创建二维数组
fso删除当前文件夹下所有的内容
<
HTML>
<
HEAD>
<
TITLE>
fso删除当前文件夹中的所有内容<
/TITLE>
<
/HEAD>
<
style>
body
{font-size:12px
margin-top:20px
margin-left:20px
}
<
/style>
<
BODY>
<
%
'功能:删除当前文件夹下所有内容,包括文件夹和文件
'开发:wangsdong
'网站:www.aspprogram.cn
'原创文章,转载请保留此信息
'创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
'创建一个Folder对象
foldername=server.mappath("./")
Set MyFolder=MyFileObject.GetFolder(foldername)
i=0
'循环显示其中文件夹
For Each thing in MyFolder.subfolders
 
if MyFileObject.folderExists(thing) then 
 
 
 
 
 
 
 
 
 
 
'判断folder文件夹是否存在
 
 
 
 
t2=thing
 
 
 
 
MyFileObject.deletefolder thing 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'删除folder文件夹
 
response.write "<
br>
"&
t2&
"-----文件夹已经删除"
 
else
 
 
 
 
response.write "<
br>
"&
thing&
"-----文件夹不存在,无法删除"
 
end if
i=i+1
Next
response.write "共有删除了"&
i&
"个文件夹<
br>
<
br>
"
'循环显示其中文件
i=0
For Each thing in MyFolder.Files
 
if MyFileObject.FileExists(thing) then 
 
 
 
 
 
 
 
 
 
 
'判断folder文件夹是否存在
 
 
 
t2=thing
 
 
 
 
MyFileObject.DeleteFile thing 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'删除folder文件夹
 
response.write "<
br>
"&
t2&
"-----文件已经删除"
 
else
 
 
 
 
response.write "<
br>
"&
thing&
"-----文件不存在,无法删除"
 
end if
i=i+1
Next
response.write "共有删除了"&
i&
"个文件"
%>
<
/Body>
<
/HTML>
fso删除当前文件夹下所有的内容