Useful function check/create path, folder on same/other computer.
Useful function check/create path, folder on same/other computer.
API Declarations
'Public mfObj As New FileSystemObject
Rate Useful function check/create path, folder on same/other computer.
(1(1 Vote))
Dim arrFolder() As String
Dim strDirX As String
Dim i As Integer, j As Integer, k As Integer
On Error GoTo showError
If strDirectory = "" Or InStr(strDirectory, "\") = 0 Then
checkPathCreate = False
Exit Function
End If
arrFolder = Split(strDirectory, "\")
If InStr(strDirectory, "\\") = 0 Then
k = 1
If Not mfObj.DriveExists(arrFolder(i)) Then
checkPathCreate = False
Exit Function
End If
strDirX = arrFolder(i)
Else
k = 4
strDirX = "\\" & arrFolder(2) & "\" & arrFolder(3)
If Not mfObj.DriveExists(strDirX) Then
checkPathCreate = False
Exit Function
End If
End If
j = UBound(arrFolder)
If withFile Then
j = j - 1
End If
For i = k To j
If InStr(arrFolder(i), ".") = 0 Then
strDirX = strDirX & "\" & arrFolder(i)
If Not mfObj.FolderExists(strDirX) Then
mfObj.CreateFolder (strDirX)
End If
End If
Next
checkPathCreate = True
Exit Function
showError:
checkPathCreate = False
End Function
Useful function check/create path, folder on same/other computer. Comments
No comments yet — be the first to post one!
Post a Comment