VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Creates a directory (and all its parent directories if neccessary)

by Walter Eigner (15 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 12th April 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Creates a directory (and all its parent directories if neccessary)

API Declarations



Dim fso As New FileSystemObject 'get this from Microsoft Scripting Run-time (scrrun.dll)



Rate Creates a directory (and all its parent directories if neccessary)



Private Sub CreateInstallDir()
CreateDir "c:\walter\dood\narj\rag\"
End Sub


'the actual function
Sub CreateDir(DirPath As String)
Dim CurDirs As New Collection
Dim i As Integer
i = 1
Do Until InStr(i, DirPath, "\", vbTextCompare) = 0
CurDirs.Add Left(DirPath, InStr(i, DirPath, "\", vbTextCompare))
i = InStr(i, DirPath, "\", vbTextCompare) + 1
Loop
For i = 1 To CurDirs.Count
If Not fso.FolderExists(CurDirs.Item(i)) Then
fso.CreateFolder CurDirs.Item(i)
End If
Next
End Sub


Download this snippet    Add to My Saved Code

Creates a directory (and all its parent directories if neccessary) Comments

No comments have been posted about Creates a directory (and all its parent directories if neccessary). Why not be the first to post a comment about Creates a directory (and all its parent directories if neccessary).

Post your comment

Subject:
Message:
0/1000 characters