Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 4th, 2005, 05:30 PM
Friend of Wrox
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default View Files in a Directory

Does anyone know the best way to get a list of files in a directory?

Currently I am using the following, but am getting an error occasionally...

    strDirPath = GetUserSetting("Import_Folder")

    If Right$(strDirPath, 1) <> "\" Then
        strDirPath = strDirPath & "\"
    End If

    If GetAttr(strDirPath) = vbDirectory Then
        strFileName = Dir(strDirPath, vbDirectory)
        Do Until Len(strFileName) = 0
            ' Exclude ".", "..".
            If (strFileName <> ".") And (strFileName <> "..") Then
                ' Make sure we do not have a sub-directory name.
                If (GetAttr(strDirPath & strFileName) _
                    And vbDirectory) <> vbDirectory Then

                    Set rs = New ADODB.Recordset
                    strSQL = "SELECT file_PK FROM D_Files WHERE file_FilePath = '" & strDirPath & strFileName & "'"
                    rs.Open strSQL, cn
                    If rs.BOF And rs.EOF Then
                        LoadFile (strDirPath & strFileName)
                    End If
                End If
            End If
            strFileName = Dir()
    End If

I got it from the Microsoft Site - in case anyone is wondering.


Old October 15th, 2005, 02:36 PM
Friend of Wrox
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts

What line gets the error?

You might also want to check this out:

search drive

"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory.GetFiles got other not related files cmyeung_99 C# 2005 0 June 29th, 2006 09:16 PM
How do I read all the xml files in a directory hkec C# 0 May 11th, 2006 01:10 AM
Active Directory and Windows System Files frleonard ASP.NET 1.x and 2.0 Application Design 0 February 25th, 2006 08:41 PM
directory view yagiroy VS.NET 2002/2003 0 June 11th, 2003 02:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.