IntroductionGetting StartedAll PostsNotesAbout The Author
Creating Directories
Friday, July 31, 2009 - 1:53 PM

This function creates the directory supplied as an argument, creating folders and subfolders as needed. The last subfolder must be followed by a backslash.


Sample usage: fCreateDirectory("H:\Folder1\Subfolder1\")



Option Explicit
Option Base 1 'this is not necessary for this function


Public Function fCreateDirectory(sDirectory$) As Boolean
'uses FileFolderExists function

    fCreateDirectory = True: On Error Goto Failed

    If Not
FileFolderExists(sDirectory) Then
        Dim
aFolders, folder$, i As Byte, j As Byte: aFolders = Split(sDirectory, "\")
        For i = 0 To UBound(aFolders) - 1
            folder = ""
            For j = 0 To i
                folder = folder & aFolders(j) & "\"
            Next
            If Not
FileFolderExists(folder) Then MkDir folder
        Next
    End If

    Exit Function
Failed
:

    fCreateDirectory = False
End Sub

<< Navigate to Friday, July 31, 2009 Add New Comment
No records found        
Add New Comment
Your name   
Subject   
Content   
*Required fields

January, 2009
February, 2009
March, 2009
April, 2009
May, 2009
June, 2009
July, 2009
August, 2009
September, 2009
October, 2009
November, 2009
December, 2009
IntroductionGetting StartedAll PostsNotesAbout The Author