|
Public Function CreateDirIfRequired(strMyPath As String)
On Error GoTo CreateDirIfRequired_Error
If Len(Dir(strMyPath, vbDirectory)) = 0 Then
MkDir strMyPath
‘创建目录
End If
On Error GoTo 0
Exit Function
CreateDirIfRequired_Error:
Resume Next
End Function
Function CreateFolder(MyPath As String)
'可创建多个子目录. "c:\dane\fred\harry"
Dim c As Integer
On Error Resume Next
If InStr(4, MyPath, "\") = 0 Then
MkDir (MyPath)
Else
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
For c = 4 To Len(MyPath)
If Mid(MyPath, c, 1) = "\" Then
MkDir Left(MyPath, c)
End If
Next c
End If
End Function |
|