Click to See Complete Forum and Search --> : filesystemwatcher
pampatipraveen
July 25th, 2002, 09:47 PM
Hi
I need a service type application , which watches wholes system for the changed files by using filesystemewatcher component. I implemented a service which can watch onely one root like "C:\". but i need to watch whole system like "C:\","D:\".....etc. How should i achieve this. I want this to be done in VB.net. can anyone please send me some sample application whcih can do this?
please reply me as early as possible
Thanking you sri
Regards
Praveen.P
mailtopampati@rediffmail.com
ilk
January 9th, 2003, 09:15 AM
Hi,
if you have found the solution could you please send me an example?
Thank you
DSJ
January 9th, 2003, 10:25 AM
I'd think you could fireup a thread for each drive you want to watch.
ilk
January 9th, 2003, 10:38 AM
i think there is no need it will be watched using windows service app.
pampatipraveen
January 9th, 2003, 06:36 PM
Hi,
i am initiating for each drive different thread in windows service starting. if you know betterway please let me know.
Dim fso As New Scripting.FileSystemObject()
Dim drive As Scripting.Drive
For Each drive In fso.Drives
If drive.DriveType = Scripting.DriveTypeConst.Fixed Then
Dim t As System.Threading.Thread = SimpleThread.CreateThread(AddressOf InitFilewatcherThread, drive.Path & "\")
t.Priority = Threading.ThreadPriority.Highest
t.Start()
End If
Next
Regards
praveenp
ilk
January 10th, 2003, 03:46 AM
I'm not sure whether this way is better I'm just not using threads.
Dim fsWatcher(-1) As System.IO.FileSystemWatcher
Private Sub addWatcher(ByVal strPath As String, ByVal strFilter As String)
ReDim Preserve fsWatcher(UBound(fsWatcher) + 1)
fsWatcher(UBound(fsWatcher)) = New System.IO.FileSystemWatcher(strPath, strFilter)
fsWatcher(UBound(fsWatcher)).EnableRaisingEvents = True
fsWatcher.IncludeSubdirectories = True
AddHandler fsWatcher(UBound(fsWatcher)).Changed, AddressOf fsEventHandler
End Sub
Private Sub fsEventHandler(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
MsgBox(e.FullPath)
End Sub
Private Sub RemoveAllWatchers()
Dim i As Integer
For i = 0 To UBound(fsWatcher)
fsWatcher(i).Dispose()
RemoveHandler fsWatcher(i).Changed, AddressOf fsEventHandler
Next
End Sub
Maybe this way it is a little bit easier to control created objects...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.