Results 1 to 2 of 2

Thread: Need help in check Folder

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    9

    Need help in check Folder

    Hai all, i need some help. I want to check is a folder being accessed or not.
    Thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Need help in check Folder

    This might help...
    VB Code:
    1. 'Author: Aaron Young (with a few added things from Jop)
    2. 'Origin: Vb-World.net forums
    3. 'Purpose: Monitor a Directory
    4. 'Version: VB5+
    5.  
    6. 'You can use the FindFirstChangeNotification() and
    7. 'FindNextChangeNotification() API's to monitor a directory
    8. 'for file changes including creation of new files, i.e.
    9.  
    10. Private Declare Function WaitForSingleObject _
    11. Lib "kernel32" (ByVal hHandle As Long, ByVal _
    12. dwMilliseconds As Long) As Long
    13.  
    14. Private Declare Function FindFirstChangeNotification _
    15. Lib "kernel32" Alias "FindFirstChangeNotificationA" _
    16. (ByVal lpPathName As String, ByVal bWatchSubtree As _
    17. Long, ByVal dwNotifyFilter As Long) As Long
    18.  
    19. Private Declare Function FindNextChangeNotification _
    20. Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    21.  
    22. Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
    23. Private Const FILE_NOTIFY_CHANGE_LAST_WRITE As Long = &H10
    24. Private Const FILE_NOTIFY_CHANGE_CREATION As Long = &H40
    25.  
    26. Private Sub WaitForFileActivity(ByVal sDirectory As String)
    27. Dim lHandle As Long
    28. Dim lReturn As Long
    29.  
    30. lHandle = FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_LAST_WRITE) 'if something's written to a file
    31. 'or FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_CREATION) 'if a file is being created
    32. 'or FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_FILE_NAME)
    33. Do
    34.    lReturn = WaitForSingleObject(lHandle, 1)
    35.    Call FindNextChangeNotification(lHandle)
    36.    DoEvents
    37. Loop While lReturn <> 0
    38. End Sub
    39.  
    40. Private Sub Command1_Click()
    41. WaitForFileActivity "C:\"
    42. MsgBox "Change", vbSystemModal
    43. End Sub

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