cano63
asked on
monitoring a file
Hello,
I have create a windows service that monitor all the files that are created in a specific directory when a new file is creted I call an application api that will load the new file, the problem that ,I,m having is that is the file.still open by other application i will not be able to upload the file to my api, Im looking a way to get to know when a file ia not more used by any other app so i can call my api
I have create a windows service that monitor all the files that are created in a specific directory when a new file is creted I call an application api that will load the new file, the problem that ,I,m having is that is the file.still open by other application i will not be able to upload the file to my api, Im looking a way to get to know when a file ia not more used by any other app so i can call my api
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi there
A couple of notes.
Seeing that you are attaching the logchange sub to the Created event of watchfolder, there is no need to test again within the sub, the change type is .created as that is the event that fired and being handled
Also look at setting watcher.notifyfilter to relevant events to track
You can also try and invoke the timer.start method to ensure that the timer has started
Hope this helps as I havn't worked with the FSW in a couple of years.
Cheers
Theo
A couple of notes.
Seeing that you are attaching the logchange sub to the Created event of watchfolder, there is no need to test again within the sub, the change type is .created as that is the event that fired and being handled
Also look at setting watcher.notifyfilter to relevant events to track
You can also try and invoke the timer.start method to ensure that the timer has started
Hope this helps as I havn't worked with the FSW in a couple of years.
Cheers
Theo
ASKER
THe code work greate,
But i continue havien a problem
I,m using the System.IO.FileSystemWatche
I atach the code
Open in new window