VB 使用两种方法创建多层文件夹:
1、使用API
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp" (ByVal PathName As String) As Long
MakeSureDirectoryPathExists "C:\111\222\333"
2、不用API
Private Sub MakeDirPath(strDirName As String)
Dim i As Long, strPath As String
Do
i = InStr(i + 1, strDirName & "\", "\")
strPath = Left$(strDirName, i - 1)
If Right$(strPath, 1) <> ":" And Dir$(strPath, vbDirectory) = "" Then
MkDir strPath
End If
Loop Until i >= Len(strDirName)
End Sub
评论