Tools Links Login

Build a Path That's Shauld Create More Than Directory

Hi All .. This Code Will Create a Path That's Shauld Make More Than One Directory .. For Example When You Call Function :
Call BuildPath ("C:A1A2A3A4")
It Will Create "C:A1" and "C:A1A2" .etc
It Will Return False If The Drive Doesnt Exist Or For Any Other Error ..
Please Send Me Your Comments ..

Original Author: Abdalla Mahmoud

Code

Function BuildPath(ByVal Path As String) As Boolean
On Error Resume Next
Dim Fnd As Long
Dim Tmp As String
Dim FileSystemObj As Object
Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
If FileSystemObj.DriveExists(FileSystemObj.GetDriveName(Path)) = False Then Exit Function
Path = Path & IIf(Right(Path, 1) = "", vbNullString, "")
Fnd = InStr(Path, "")
Do While Fnd
Tmp = Tmp & Left(Path, Fnd)
Path = Mid(Path, Fnd + 1)
MkDir Tmp
If FileSystemObj.DriveExists(Tmp) = False And FileSystemObj.FolderExists(Tmp) = False Then Exit Function
Fnd = InStr(Path, "")
Loop
BuildPath = True
End Function
Private Sub Command1_Click()
Call BuildPath("C:A1A2A3A4A5A6A7")
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 89 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.