[AccessD] FS object

John W. Colby jwcolby at colbyconsulting.com
Tue May 4 19:49:00 CDT 2004


>Have I said before I hate the FS object...

No doubt.

Not sure exactly why.  It is just an object model that allows manipulation
of the file system.  Why not hate DAO?  Why not hate the Excel object model?
Why not hate ...

Never mind.

It's just a tool.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Jürgen Welz
Sent: Tuesday, May 04, 2004 8:08 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] FS object


Have I said before I hate the FS object...

Public Function fnCreateBasePath(strCreatePath As String) As Boolean

    On Error GoTo ErrorHandler

Dim strPath As String
Dim lngPosition As Long

    strCreatePath = Trim(strCreatePath)
    If Right$(strCreatePath, 1) <> "\" Then strCreatePath = strCreatePath &
"\"
    lngPosition = 2
    Do Until lngPosition = 1
        lngPosition = InStr(lngPosition + 1, strCreatePath, "\")
        If lngPosition > 0 Then
            strPath = Left$(strCreatePath, lngPosition - 1)
            If Not Len(Dir(strPath, vbDirectory)) > 0 Then MkDir strPth
        End If
        lngPosition = lngPosition + 1
    Loop
    fnCreateBasePath = Len(Dir(strPath, vbDirectory))

ExitRoutine:
    On Error Resume Next
    Exit Function
ErrorHandler:
    With Err
        Select Case .Number
            Case Else
                MsgBox .Number & vbCrLf & .Description & vbCrLf & vbCrLf & _
                " Error in creating Folder:  '" & strCreatePath & "'", _
                vbInformation, "Error - fnCreateBasePath"
        End Select
    End With
    'Resume 0
    Resume ExitRoutine
End Function

Call it like so:

fncreatebasepath("C:\min\max\boo")

I culled this from some other work that I had done that had a guaranteed
fixed path so I was able to initialize lngposition at 22.  It formerly
worked with UNC and mappings but this is just a quick post without testing
because, as I said, I always had a fixed starting path.


Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com

_________________________________________________________________
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=htt
p://hotmail.com/enca&HL=Market_MSNIS_Taglines

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list