Share this with your friends 

Creating folders dynamically in Vb6

0 ratings Views 672 
Author: MAHESH_9bd00526 (MAHESH KUMAR SANKA)  View Profile |  View other solutions by this author

Question / Problem

Creating the folders dynamically ,if exists not creating else creating


Public Function CreateFolder(destDir As String) As Boolean
Dim i As Long
Dim prevDir As String

On Error Resume Next

For i = Len(destDir) To 1 Step -1
If Mid(destDir, i, 1) = "\" Then
prevDir = Left(destDir, i - 1)
Exit For
End If
Next i

If prevDir = "" Then CreateFolder = False: Exit Function
If Not Len(Dir(prevDir & "\", vbDirectory)) > 0 Then
If Not CreateFolder(prevDir) Then CreateFolder = False: Exit Function
End If

On Error GoTo errDirMake
MkDir destDir
CreateFolder = True
Exit Function

CreateFolder = False

End Function

Applies to

VB 2005 ,C# 2005, .Net 2.0 Windows Forms, Asp.Net 2.0

Rank It

Login to rank it