|
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 |