Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different commands, is there an easy way similar to Directory.CreateDirectory()
+4
A:
Here's some code I used in one of my projects. It requires a reference be added to the project for the file system object.
First, click Project -> References, scroll down to "Microsoft Scripting Runtime" and select it. Then you can use this function:
Public Sub MakePath(ByVal Folder As String)
Dim arTemp() As String
Dim i As Long
Dim FSO As Scripting.FileSystemObject
Dim cFolder As String
Set FSO = New Scripting.FileSystemObject
arTemp = Split(Folder, "\")
For i = LBound(arTemp) To UBound(arTemp)
cFolder = cFolder & arTemp(i) & "\"
If Not FSO.FolderExists(cFolder) Then
Call FSO.CreateFolder(cFolder)
End If
Next
End Sub
G Mastros
2008-11-12 19:57:17
A:
Beaner
2008-11-14 16:40:25