asp快速删除文件夹和文件

2024-09-11阅读:2605

写了个asp删除文件和文件夹的函数,可以把它写到公共文件里,然后用的时候是 call fileDel("file",1) 其中的file是文件的路径,可以是绝对目录也可以是相对目录,1为删除目录,如果不是1则删除的为文件

function fileDel(path,lei)'path目录,lei如果是1则删除目录,否则为文件
    path=Server.MapPath(path)
    Set fso = CreateObject("Scripting.FileSystemObject")
    if lei=1 then
        If fso.FolderExists(path) Then
        Set f = fso.GetFolder(path)
        f.delete()
        Set f = Nothing
        fileDel=true
        else
        fileDel=false
        End If
    else
        If fso.FileExists(path) Then
            Set f = fso.GetFile(path)
            f.delete()
            Set f = Nothing
        fileDel=true
        else
        fileDel=false
        End If
    end if
end function


大家都爱看
查看更多热点文章