Advertisement
ASP_Volume3 String Manipulation #61878

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:\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 ..

AI

Résumé par IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Code source
original-source
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
Commentaires originaux (3)
Récupéré via Wayback Machine