您的位置:首页 > 其它

fso删除当前文件夹下所有的内容

2008-11-26 20:52 309 查看
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>http://www.corange.cn/archives/2008/09/1619.html

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  each
相关文章推荐