Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File directory monitor

Status
Not open for further replies.

PRMiller2

Technical User
Jul 30, 2010
123
I currently have a form that runs a timer event every x milliseconds. It checks to see if a file exists in a certain directory and returns a value (1) if one does exist:

Code:
If FileExists("C:\Mypath\Queue\*.*") = True Then
...

I'm trying to build this out so that the program detects whether or not a file has been dropped into this directory and then acts on it, based on some logic. It is possible that more than one file will be dropped in at a time, but it does not matter in what order the files are processed.

I would like my module to retrieve the name of the next file to work and parse it's prefix, checking against a lookup table or code to determine what process to take. For example:

Code:
Dim strFileName as String

...

Select Case Left(strFileName, 3)
     Case "ONE"
          DoThis
     Case "TWO"
          DoThat
End Select

My question is, how to I retrieve the name of a file once FileExists is true?

Thanks,
Paul
 
You can use the Dir() function to return a file name. Test with a function like:
Code:
Public Function GetFiles(strFolder As String) As String
    Dim strFile As String
    strFile = Dir(strFolder)
    Debug.Print strFile
    Do Until Len(strFile) = 0
        strFile = Dir() & ""
        Debug.Print strFile
    Loop
End Function

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top