用FSO删除文件夹

删除文件夹
dim fso=server.createobject("script.fileSystemObject")
if fso.folderexists(Server.MapPath(filename))  then
    fso.deleteFolder(Server.MapPath(filename))
end if

 删除文件
if fso.FileExists(Server.MapPath(filename)) then
  fso..DeleteFile(Server.MapPath(filename))
end if


删除文件函数:


Function DeleFile(FilePath)
 On Error Resume Next
 Set Del=Server.CreateObject("Scripting.FileSystemObject")
 if Err <> 0 Then
  DelFile="该空间不支持FSO组件或者文件路径错误!"
 else
  if InStr(FilePath, ",") > 0 then
   FilePath=Split(FilePath,",")
   For i = 0 to ubound(FilePath)
    If Del.FileExists(Server.MapPath(FilePath))=True Then Del.DeleteFile Server.MapPath(FilePath(i)),true
   Next
  Else
   If Del.FileExists(Server.MapPath(FilePath))=True Then Del.DeleteFile Server.MapPath(FilePath),true
  End if
 End if
 Set Del=Nothing
End Function

你可能感兴趣的:(asp,function)