|
-
Feb 12th, 2001, 05:05 AM
#1
Thread Starter
Member
How to check whether there are some changes in directory.
File added,
file deleted,
changes made to file.
Thanks,
Milind
-
Feb 12th, 2001, 11:45 AM
#2
Frenzied Member
ANY changes:
Check on the date of the directory.
What changes:
Not so easy......
-
Feb 12th, 2001, 08:07 PM
#3
Try this:
Code:
'Author: Aaron Young
'Origin: Vb-World.net forums
'Purpose: Monitor a Directory
'Version: VB5+
You can use the FindFirstChangeNotification() and
FindNextChangeNotification() API's to monitor a directory
for file changes including creation of new files, i.e.
Private Declare Function WaitForSingleObject _
Lib "kernel32" (ByVal hHandle As Long, ByVal _
dwMilliseconds As Long) As Long
Private Declare Function FindFirstChangeNotification _
Lib "kernel32" Alias "FindFirstChangeNotificationA" _
(ByVal lpPathName As String, ByVal bWatchSubtree As _
Long, ByVal dwNotifyFilter As Long) As Long
Private Declare Function FindNextChangeNotification _
Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
Private Const FILE_NOTIFY_CHANGE_LAST_WRITE As Long = &H10
Private Const FILE_NOTIFY_CHANGE_CREATION As Long = &H40
Private Sub WaitForFileActivity(ByVal sDirectory As String)
Dim lHandle As Long
Dim lReturn As Long
lHandle = FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_LAST_WRITE) 'if something's written to a file
'or FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_CREATION ) 'if a file is being created
'or FindFirstChangeNotification(sDirectory, 0&, FILE_NOTIFY_CHANGE_FILE_NAME)
Do
lReturn = WaitForSingleObject(lHandle, 1)
Call FindNextChangeNotification(lHandle)
DoEvents
Loop While lReturn <> 0
End Sub
Private Sub Command1_Click()
WaitForFileActivity "C:\"
MsgBox "Change", vbSystemModal
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|