FileSystemWatcher question

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
 
T

Tim Haughton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top