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

/ / 2016-07-24   阅读:2490
<HTML> <HEAD><TITLE>fso删除当前文件夹中的所有内容</TITLE></HEAD> <style> body {font-size:12px;margin-top:20px;margin-left:20px;} </style> <BODY> &...
<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>

我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈