一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

自动创建多级目录,有则跳过 无则创建,

时间:2010-03-15 编辑:简简单单 来源:一聚教程网

 Function AutoCreateFolder(strPath) ' As Boolean
  On Error Resume Next

  Dim astrPath, ulngPath, i, strTmpPath
  Dim objFSO

  If InStr(strPath, "") <=0 or InStr(strPath, ":") <= 0 Then
   AutoCreateFolder = False
   Exit Function
  End If
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  If objFSO.FolderExists(strPath) Then
   AutoCreateFolder = True
   Exit Function
  End If
  astrPath = Split(strPath, "")
  ulngPath = UBound(astrPath)
  strTmpPath = ""
  For i = 0 To ulngPath
   strTmpPath = strTmpPath & astrPath(i) & ""
   If Not objFSO.FolderExists(strTmpPath) Then
    ' 创建
    objFSO.CreateFolder(strTmpPath)
   End If
  Next
  Set objFSO = Nothing
  If Err = 0 Then
   AutoCreateFolder = True
  Else
   AutoCreateFolder = False
  End If
 End Function

热门栏目