ASP删除非空目录的例子
类别: ASP教程
这是个删除非空目录的例子
\'test.asp
\'要执行删除你需要对该目录具有修改权限
<%
dim fso,tmpfolder,tmpsubfolder,tmpfile,tmpfiles
set fso=server.CreateObject("Scripting.FileSystemObject")
sub delfolder(sPath)
If (fso.FolderExists(server.MapPath (sPath))) then
set tmpfolder=fso.GetFolder(server.MapPath (sPath))
set tmpfiles=tmpfolder.files
for each tmpfile in tmpfiles
fso.DeleteFile (tmpfile)
next
set tmpsubfolder=tmpfolder.SubFolders
for each tmpfolder in tmpsubfolder
\'response.Write spath&"/"&tmpfolder.name
delfolder(spath&"/"&tmpfolder.name )
next
fso.DeleteFolder (server.MapPath (sPath))
end if
end sub
%>
<%
\'调用例子
\'test.asp放到wwwroot下
\'wwwroot1存在,且其他下有若干子目录和文件
delfolder("1")
%>
\'test.asp
\'要执行删除你需要对该目录具有修改权限
<%
dim fso,tmpfolder,tmpsubfolder,tmpfile,tmpfiles
set fso=server.CreateObject("Scripting.FileSystemObject")
sub delfolder(sPath)
If (fso.FolderExists(server.MapPath (sPath))) then
set tmpfolder=fso.GetFolder(server.MapPath (sPath))
set tmpfiles=tmpfolder.files
for each tmpfile in tmpfiles
fso.DeleteFile (tmpfile)
next
set tmpsubfolder=tmpfolder.SubFolders
for each tmpfolder in tmpsubfolder
\'response.Write spath&"/"&tmpfolder.name
delfolder(spath&"/"&tmpfolder.name )
next
fso.DeleteFolder (server.MapPath (sPath))
end if
end sub
%>
<%
\'调用例子
\'test.asp放到wwwroot下
\'wwwroot1存在,且其他下有若干子目录和文件
delfolder("1")
%>
- 上一篇: ASP与TXT组合设计程序的实例
- 下一篇: 详细讲解ASP脚本循环语句
-= 资 源 教 程 =-
文 章 搜 索