Fw: Create Directory if does not exist

0 views
Skip to first unread message

Neeraj Shinde

unread,
Jun 24, 2005, 2:12:53 AM6/24/05
to ProgrammingGuru

----- Original Message -----
From: "Neeraj Shinde" <neeraj...@gmail.com>
To: <neeraj...@gmail.com>
Sent: Tuesday, October 26, 2004 2:36 PM
Subject: Create Directory if does not exist


> Function NewDirIfInexistent(Path As String) As Integer
> 'Return values:
> ' 0 = path already exists
> ' 1 = new path was created
> ' 2 = path does not exist and could not be created
> Dim strPath As String, x As Integer
> If Right$(Path, 1) <> "\" Then Path = Path & "\"
> On Local Error GoTo 10
> If Dir(Path, vbDirectory) <> "" Then
> NewDirIfInexistent = 0
> Else
> 5 x = InStr(x + 1, Path, "\")
> If x > 0 Then
> strPath = Left$(Path, x)
> If Dir(strPath, vbDirectory) = "" Then MkDir (strPath)
> GoTo 5
> End If
> NewDirIfInexistent = 1
> End If
> Exit Function
> 10 NewDirIfInexistent = 2
> End Function
>
>
> --
> Regards,
> Neeraj Shinde
> Email : neeraj...@rediffmail.com
> URL : http://www.neerajshinde.cjb.net
Reply all
Reply to author
Forward
0 new messages