Results 1 to 2 of 2

Thread: Monitor a Directory?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    In another project i am working on, i want a user to be notified when there is a new file in a directory. How can i write something that scans a directory on a given interval and look for only new files? If possible, i want to pass the file name to the program so they can open the file if they choose to at my prompt.

    Thanks,

    Rob

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I cannot guarantee that this will work, it was found in my half-done folder. If you encounter errors, reply. The function will return a variant containing an array.

    Function SearchDIR(directory)
    On Error Resume Next
    Static dirname
    Static oldfiles() As String
    Static newfiles() As String
    Static foundfiles() As String
    ReDim newfiles(0) As String
    fil = Dir(directory)
    Do Until fil = ""
    If fil <> "." And fil <> ".." Then
    ReDim Preserve newfiles(UBound(newfiles) + 1)
    newfiles(UBound(newfiles)) = fil
    test = oldfiles(0)
    If Err Then
    For n = 0 To UBound(oldfiles)
    If newfiles(UBound(newfiles)) = oldfiles(n) Then ReDim Preserve foundfiles(UBound(foundfiles) + 1): foundfiles(UBound(foundfiles)) = newfiles(UBound(newfiles)): Exit For
    Next n
    End If
    End If
    fil = Dir()
    Loop
    ReDim oldfiles(UBound(newfiles))
    For Each n In newfiles
    oldfiles(n) = newfiles(n)
    Next n
    SearchDIR = foundfiles()
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width