JulianDavies
asked on
Watching folders...
Is it possible (preferably without the use of timers) to "watch" a folder on the local hard-disk. i.e. somehow fire an event when a file is added to the folder?
Any help with this would be greatly appreciated.
Thanks!
Julian
Any help with this would be greatly appreciated.
Thanks!
Julian
<ping>
don't think so but why don't you want to use timers?? then it's easy.....
Make a reference to microsoft scripting runtime.
Add a timer to your form
Private sc As New Scripting.FileSystemObject
Private lastModified As String
Private Sub dowhatever()
MsgBox "changed"
End Sub
Private Sub CHFiles(ByVal path As String)
Dim f As Scripting.Folder, tmp As String
Set f = sc.GetFolder(path)
tmp = f.DateLastAccessed
If (tmp <> lastModified) Then
lastModified = f.DateLastAccessed
dowhatever
End If
End Sub
Private Sub Timer1_Timer()
Call CHFiles(App.path)
End Sub
Add a timer to your form
Private sc As New Scripting.FileSystemObject
Private lastModified As String
Private Sub dowhatever()
MsgBox "changed"
End Sub
Private Sub CHFiles(ByVal path As String)
Dim f As Scripting.Folder, tmp As String
Set f = sc.GetFolder(path)
tmp = f.DateLastAccessed
If (tmp <> lastModified) Then
lastModified = f.DateLastAccessed
dowhatever
End If
End Sub
Private Sub Timer1_Timer()
Call CHFiles(App.path)
End Sub
Sorry, i thought it wrote "preferable with the user of timers" :-(...sorry about that then :-/
regards,
CJ
regards,
CJ
You can use Sleep API instead of Timer control.....
I don't think it is possible without checking the folder frequrntly after a small event of time. It'll be neccassary to check the folder changed on regular intervals of time.
Ajay chadha ... :-)
I don't think it is possible without checking the folder frequrntly after a small event of time. It'll be neccassary to check the folder changed on regular intervals of time.
Ajay chadha ... :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's exactly what I needed. Thank you!