asp刪除非空目錄的例子
發(fā)表時間:2024-06-07 來源:明輝站整理相關軟件相關文章人氣:
[摘要]這是個刪除非空目錄的例子'test.asp'要執(zhí)行刪除你需要對該目錄具有修改權限<%dim fso,tmpfolder,tmpsubfolder,tmpfile,tmpfilesset fso=server.CreateObject("Scripting.FileS...
這是個刪除非空目錄的例子
'test.asp
'要執(zhí)行刪除你需要對該目錄具有修改權限
<%
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\下
'wwwroot\1\存在,且其他下有若干子目錄和文件
delfolder("1")
%>