<HTML>
<HEAD><TITLE>fso删除当前文件夹中的所有内容</TITLE></HEAD>
<style>
body {font-size:12px;margin-top:20px;margin-left:20px;}
</style>
<BODY>
<%
'开发:wangsdong
'网站:www.aspprogram.cn
'原创文章,转载请保留此信息
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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。