I would use the filesystemwatcher to trap files changes into a specific
directory.
I take a look on the possible message, and 'cause I need to know only
when a files finishede to have been copy, I user the LastAccess
message.
I do a simple project, and there all works fine. So I moved all into
the main project, a service. I then installed the FTP service on the
working pc and did a try. Unfortunately running this sample (the
machine is the same of the previous test) there the message if fired
just after the file is created.
I don't know why the behaviour occur. Certainly LastAccess doesn't mean
last byte written, and file system architecture is quite different from
what you think I'm thinking, I know. My question is just to know how
this strange thing happen.
A part of all. I thinked to solve the problem (know when file has been
completely write) using a timer. When the file system event fires I add
an entry into an hashtable or bi-dimensional array, in which I take
trace of file's name and date-time, then fires the timer every 10
seconds. If, for example, for 3 times the last-access time stored in
the array hasn't been changed, I can consider the file written (well or
not, this certainly could be another problem, but because I'll zip
file, if it won't be completely written, it'll certainly unreadable).
What do you think of that?
Thanks Andrea