Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old October 4th, 2005, 05:30 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
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()
        Loop
    End If

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

Thanks

Mike
EchoVue.com
__________________
Mike
EchoVue.com
  #2 (permalink)  
Old October 15th, 2005, 02:36 PM
Friend of Wrox
 
Join Date: Jul 2005
Location: Oklahoma City, OK, USA.
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What line gets the error?

You might also want to check this out:

search drive



Boyd
"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
http://www.officeprogramming.com


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.