当前位置:编程学习 > asp >>

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

自动创建多级目录,有则跳过 无则创建,
 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

补充:asp教程,高级应用
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,