程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp生成目錄與無限生成多級目錄創建

asp生成目錄與無限生成多級目錄創建

編輯:關於ASP編程

    asp教程生成目錄與無限生成多級目錄創建
    這裡提供二款asp目錄生成函數,第一款是只能創建一級目錄,後一款函數可以支持多目錄同時生成。
     

    sub efolder(foldername)
    dim fso
    set fso=server.createobject("scripting.filesystemobject")
    if fso.folderexists(server.mappath(foldername)) then
    set fso=nothing
    exit sub
    else
    fso.createfolder(server.mappath(foldername))
    end if
    set fso=nothing
    end sub
    ===================================================================

    sub arrayfolder(path,sep)
    dim arraypath,epath,newpath
    arraypath = split(path,sep)
    newpath=""
    for each epath in arraypath
    newpath=newpath&epath&"/"
    newpath = replace(newpath,"//","/")
    efolder newpath
    next
    end sub

    arrayfolder "1/2/3","/"

    生成多級目錄

    '建立目錄的程序,如果有多級目錄,則一級一級的創建
    function createdir(byval localpath)
    on error resume next
    localpath = replace(localpath,"","/")
    set fileobject = server.createobject("scripting.filesystemobject")
    patharr = split(localpath,"/")
    path_level = ubound(patharr)
    for i = 0 to path_level
    if i=0 then pathtmp=patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"
    cpath = left(pathtmp,len(pathtmp)-1)
    if not fileobject.folderexists(cpath) then fileobject.createfolder cpath
    next
    set fileobject = nothing
    if err.number <> 0 then
    createdir = false
    err.clear
    else
    createdir = true
    end if
    end function%>

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved