Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file watcher attributes 1

Status
Not open for further replies.

cruise95

Programmer
Oct 7, 2003
56
US
My program should look into a folder and perform actions on every file that arrives in that folder only. The file is then moved to a different folder so that file is not processed again.

The files appear in that folder after being FTP-ed from a mainframe elsewhere. Thus once the files initially appear, the may still be recieving data for 10 - 20 minutes.

In VB6 an infinite loop was used to loop through any files that were in the folder and testing if they could be accessed (or read from) before processing them.

Now I would rather use the fileWatcher in VB.NET. The problem is that I do not know what attributes to assign to the watcher so that the wathcher only sees the files once they are completely downloaded (and not just when the first appear in the directory).

Question:
Does anyone know of any attributes that can be used or how I should go about doing this? I would also appreciate any links that help explain this (The msdn library was a liitle vague about this circumstance).


Thank you for any help
 
Yeah, that can be a problem as the Created event is fired as soon as the file is created.

As a workaround you can try to open the file exclusively first :



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanx for that article ca8msm. Like the article I am also waiting for files to be completely downloaded before reading/searching through the file and recording some of its properties in MS SQL.

I am going through it while testing out some other fileWatcher attributes.


Right now I am using:
watcher.NotifyFilter = IO.NotifyFilters.LastAccess

And the handler:
AddHandler watcher.Changed, AddressOf OnChange


This seems to be working now...but there's always more testing so it may not work later!

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top