VB icon

Build a Path That's Shauld Create More Than Directory

Email
Submitted on: 1/31/2015 11:11:00 AM
By: Abdalla Mahmoud (from psc cd)  
Level: Beginner
User Rating: By 6 Users
Compatibility: VB 6.0
Views: 540
 
     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:\A1\A2\A3\A4") It Will Create "C:\A1" and "C:\A1\A2" .etc It Will Return False If The Drive Doesnt Exist Or For Any Other Error .. Please Send Me Your Comments ..
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Build a Path That's Shauld Create More Than Directory
' Description: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:\A1\A2\A3\A4")
It Will Create "C:\A1" and "C:\A1\A2" .etc
It Will Return False If The Drive Doesnt Exist Or For Any Other Error ..
Please Send Me Your Comments ..
' By: Abdalla Mahmoud (from psc cd)
'**************************************

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:\A1\A2\A3\A4\A5\A6\A7")
End Sub


Other 9 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.