FileSystemWatcher question

  • Thread starter Thread starter Piotr Szukalski
  • Start date Start date
P

Piotr Szukalski

Hi!

FileSystemWatcher raises 'Created' event immediately after the file has been
created - and what if someone transfers a very large file? Is there a bether
way to detect end of transmission than:

// --- wait for file transfer completed
while (! TryToOpenInExclusiveMode())
{
Sleep(someTime);
}
// --- file transfer completed

Best regards,
Piotrek
 
Piotr Szukalski said:
Hi!

FileSystemWatcher raises 'Created' event immediately after the file has been
created - and what if someone transfers a very large file? Is there a bether
way to detect end of transmission than:

// --- wait for file transfer completed
while (! TryToOpenInExclusiveMode())
{
Sleep(someTime);
}
// --- file transfer completed

This is more or less how I've done it in the past. I create my own
FileSystemWatcher that mimicks the interface of the .Net one. The difference
being that I only fire the created event when I can get an exclusive lock.

There may be a better way, it's just never been a big enough problem before.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
Back
Top