VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create Dir (Folder)

by Bibikoff Leonid (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

this code creates folder with any number of subfolders beneath it. MkDir can't do this!
sorry 4 my english :)

Inputs
Path as string
Assumes
paste this code in new module in immediate window type for example CreateDir "c:\rrr\ggg\jjj\kkk"

Rate Create Dir (Folder)

Sub CreateDir(strPath As String)
On Error Resume Next
Dim ArrFolders As Variant
ArrFolders = Split(strPath, "\")
dim i as long
Dim CurPath As String: CurPath = ArrFolders(0)
MkDir CurPath
For i = 1 To UBound(ArrFolders)
  CurPath = CurPath & "\" & ArrFolders(i)
  MkDir CurPath
Next i
On Error GoTo 0
If Len(Dir(strPath, vbDirectory)) = 0 Then
  Err.Raise vbObjectError, , "Can't create dir" & vbCrLf & strPath & vbcrlf & ":(((("
End If
End Sub

Download this snippet    Add to My Saved Code

Create Dir (Folder) Comments

No comments have been posted about Create Dir (Folder). Why not be the first to post a comment about Create Dir (Folder).

Post your comment

Subject:
Message:
0/1000 characters