VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Useful function check/create path, folder on same/other computer.

by Ulhas Aswar (4 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 3rd November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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.



    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


Download this snippet    Add to My Saved Code

Useful function check/create path, folder on same/other computer. Comments

No comments have been posted about Useful function check/create path, folder on same/other computer.. Why not be the first to post a comment about Useful function check/create path, folder on same/other computer..

Post your comment

Subject:
Message:
0/1000 characters