|
给定指定路径,则创建这个路径中的所有文件夹。
例如,文件路径:"E:\movies\us\thred.mp4"
则此函数会创建文件夹:"movies","us"
- Public Sub CreateFolder(ByVal FilePath As String)
- Dim arr() As String
- Dim i As Long
- Dim curPath As String
-
- FilePath = Replace(FilePath, "\", "")
-
- If Dir(FilePath, vbDirectory) = "" Then
- FilePath = Mid(FilePath, 1, InStrRev(FilePath, ""))
- End If
-
- arr = Split(FilePath, "")
-
- For i = 0 To UBound(arr)
- If curPath = "" Then
- curPath = curPath & arr(i)
- Else
- curPath = curPath & "" & arr(i)
- End If
-
- If Dir(curPath, vbDirectory) = "" Then
- MkDir curPath
- End If
- Next i
- End Sub
复制代码
|
|