日期:2007-3-30 11:43:48 出处:本站原创 作者:ggx1982 人气:
动态生成完整多层的文件夹路径

一时需要随便写的自己用的,不是很完善,不过能正常使用.

'================================================
'作  用:动态生成完整文件目录路径
'参  数:filepath ----路径格式为/fpath1/fpath2/fpath3
'返回值:True  ----成功
'        False ----失败
'================================================
Public Function CreatFiles(filepath)
Set fso = CreateObject("Scripting.FileSystemObject")
'if instr(filepath,"/")>0 then
   dim szys,hii,hhii,fdir,tpath,tmpnumber
    tpath=""
 hhii=0
    szys=split(filepath,"/")
    if left(filepath,1)="/" then
    tmpnumber=1
    else
    tmpnumber=0
    end if
       for hii=tmpnumber to ubound(szys)
          if hhii=0 then
           tpath="/"&szys(hii)
          else
           tpath=tpath&"/"&szys(hii)
          end if
          fdir=server.mappath(tpath)
            if (not fso.FolderExists(fdir)) then
              fso.CreateFolder(fdir)
            end if
  hhii=hhii+1
       next
 set fso=nothing
CreatFiles=true
End Function