[AccessD] FS object

John W. Colby jwcolby at colbyconsulting.com
Tue May 4 20:01:24 CDT 2004


How about:

Function FSCreateFolderPath(strPath As String)
On Error GoTo Err_FSCreateFolderPath

Dim col As Collection
Dim intPos As Integer
Dim strToken As String
Dim strTempPath As String

    Set col = New Collection
    strTempPath = strPath
    intPos = InStr(strTempPath, "\")
    While intPos > 0
        strToken = Left$(strTempPath, intPos)
        strTempPath = Right$(strTempPath, Len(strTempPath) - intPos)
        intPos = InStr(strTempPath, "\")
        col.Add strToken, strToken
    Wend
    strTempPath = ""
    While col.Count > 0
        strTempPath = strTempPath & col(1)
        col.Remove (1)
        fs.CreateFolder strTempPath
    Wend

Exit_FSCreateFolderPath:
On Error Resume Next

Exit Function
Err_FSCreateFolderPath:
    Select Case Err
    Case 70 'Permission denied (trying to create a drive letter)
        Resume Next
    Case 58 'Dir already exists
        Resume Next
    Case Else
        MsgBox Err.Description, , "Error in Function
basTest.FSCreateFolderPath"
        Resume Exit_FSCreateFolderPath
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Function

This is a method of a class wrapper with the FS object declared in the class
header.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Mitsules, Mark
S. (Newport News)
Sent: Tuesday, May 04, 2004 4:58 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] FS object


How about:

   Set SubFolders = MainFolder.SubFolders
   Set SubFolder = SubFolders.Add("NewSubFolder")



Mark


-----Original Message-----
From: Mitsules, Mark
Sent: Tuesday, May 04, 2004 4:48 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] FS object


Yikes!  ...but your error handler works;)


Mark



-----Original Message-----
From: John W. Colby [mailto:jwcolby at colbyconsulting.com]
Sent: Tuesday, May 04, 2004 4:43 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] FS object


yes, but have you tried directly creating a multi-level path?

John W. Colby
www.ColbyConsulting.com







More information about the AccessD mailing list