VB projects - File Watcher
Description: Program that monitors changes in selected directory (adding/deleting files)
Minimum requirements: vb
Download: source code
Screenshot:

Project: Standard EXE
Controls: Drive1 (DriveListBox), Dir1 (DirListBox), File1 (FileListBox), tmr (Timer), cmdStart (Command button)
Code:
Dim nCount As Long
Private Sub cmdStart_Click()
If cmdStart.Caption = "Start" Then
cmdStart.Caption = "Stop"
nCount = File1.ListCount
tmr.Enabled = True
Else
tmr.Enabled = False
cmdStart.Caption = "Start"
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.List(Dir1.ListIndex)
End Sub
Private Sub Drive1_Change()
If InStr(Drive1.Drive, ":") <> 0 Then
Dir1.Path = Left(Drive1.Drive,
InStr(Drive1.Drive, ":"))
Else
Dir1.Path = Drive1.Drive & "/"
End If
End Sub
Private Sub tmr_Timer()
File1.Refresh
If File1.ListCount > nCount Then
MsgBox "File has been added"
nCount = File1.ListCount
ElseIf File1.ListCount < nCount Then
MsgBox "File has been deleted"
nCount = File1.ListCount
End If
End Sub
|