asp刪除文件夾目錄

字號(hào):


    用asp寫(xiě)了一個(gè)函數(shù),asp刪除指定文件夾里面的所有內(nèi)容,看看能看懂么?
    <%@language="vbscript"%>
    <%Option Explicit%>
    <%
    'asp獲取當(dāng)前物理路徑
    Dim foraspcnbase,foraspcndelpath,foraspcntemp,foraspcntemp_array
    Dim foraspcnFos'
    Set foraspcnFos = server.CreateObject("scripting.filesystemobject")
    If not IsObject(foraspcnFos) Then response.write ("不支持FOS!,結(jié)束!"),response.End()
    foraspcnbase = request.ServerVariables("APPL_PHYSICAL_PATH")'獲取當(dāng)前站點(diǎn)物理路徑
    Function Foraspcn(path)
    Dim path_folder,path_array,temp_path,filename,filename_array
    If not foraspcnFos.FolderExists(path) Then
    Foraspcn = False
    Exit Function
    End if
    '如果是文件夾則開(kāi)始遍歷
    Set path_folder = foraspcnFos.GetFolder(path)
    set path_array = path_folder.Subfolders'
    For each temp_path In path_array
    If foraspcn(temp_path) Then
    foraspcnFos.DeleteFolder(temp_path)
    End if
    Next
    '刪除目前所屬文件夾內(nèi)文件
    Set filename = path_folder.files
    For each filename_array In filename
    foraspcnFos.DeleteFile path&"\"&filename_array.name
    Next
    Foraspcn = true
    End Function
    foraspcndelpath = foraspcnbase&"a"'刪除根目錄下的a文件夾以及里面所有內(nèi)容
    If foraspcn(foraspcndelpath) Then
    response.write "刪除成功"
    Else
    response.write "刪除失敗"
    End if
    %>
    這個(gè)有個(gè)缺陷是不能刪除自身所屬文件夾(這理指的是a),再考慮寫(xiě)個(gè)新的asp刪除文件夾