B4J Question [jFileWatcher] Creation raises twice

Blueforcer

Well-Known Member
Licensed User
Longtime User
I will track my download folder with jFileWatcher.
But if i download a single file from browser, the CreationDetected Event raises twice.
How can i prevent this?
 

OliverA

Expert
Licensed User
Longtime User
How can i prevent this?
Are you sure you are not getting a creation event for the temp file the browser creates and then another one for the actual file it creates? So you may need to ignore any of the temp files and only act on the actually finished download file.
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Youre right! unfortunally the filename is the same. so it works if i check the filesize>0 and then start my actions.
Thank you
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
It also seems that modify a file, raises the ModificationDetected event very often depending on the editor.
I modify a txt file with Visual Studio code. save it and the event raises 2-4 times. it does not happen with the windows editor
Is there a way to delay the detection or something like this?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
You could try keeping track of time. Once an event is raised, enable a timer (say 30 seconds or more, depending how often the events happen). If something happens during that time, reset the timer. If the timer activates, treat the event as occurred. It’s not a perfect solution, since it introduces a delay, but it may be a workaround for your situation.
 
Upvote 0
Top