/build/static/layout/Breadcrumb_cap_w.png

VB script for creating a directory

I want to check if C:\Test\Log exits if not create C:\Test\Log.
I used the script to create a folder which creates only till C:\Test.
Not really sure how to create the complete path.
Please help...its highly important..Thanks

0 Comments   [ + ] Show comments

Answers (3)

Posted by: itolutions 13 years ago
Purple Belt
0

Sub CreateRecursiveDirectory(LocalPath)
On Error Resume Next
if Not oFSO.FolderExists(LocalPath) Then
if Not oFSO.FolderExists(oFSO.GetParentFolderName(LocalPath)) Then
CreateRecursiveDirectory(oFSO.GetParentFolderName(LocalPath))
End if
oFSO.CreateFolder(LocalPath)
Else
oFSO.GetFolder(LocalPath)
End If
On Error Goto 0
End Sub


Example of using:


CreateRecursiveDirectory "C:\bd\data\notes"
Posted by: captain_planet 13 years ago
Black Belt
0
Nice script! [;)]

Just so the OP isn't scratching his head forever and a day, you'll have to create the FileSystemObject first at the top.....
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Posted by: VATMAN 13 years ago
Orange Belt
0
Thanks a lot
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ