FileSystemWatcher

R

Romain TAILLANDIER

Hi group,

I have created a very simple application to test the FileSystemWatcher.
It is great !
I get all the event possible.

but i need to make an operation AFTER a file is written, the
FileSystemWatcher must detect the end of a writting operation on a
file, and then call to the operation.

if i use the 'created' event with a big file, the operation is starting
before the end of writing the file.
if i use the 'changed' event i get a number of event depending on the
size of the file, or a single event on the file creation.

how can i detect the end of a writing operation ?
and what are the good System.IO.NotifyFilters combinaison for achieve
it ?

thank you
ROM
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

It;s not possible, if you look into the archives you will see that there is
no an "end of written" event, as a matter of fact you may get more than one
notifications for a write operation.

Two options, if you create the file in another program then you could create
another file that works as a flag.
otherwise you will have to keep trying until you can modify it :)
 
W

William Stacey [MVP]

IIRC, you can, however, catch a rename event. So download the file as
"tmpfilexxx.xxx". Then after complete, rename the file to the real file
name. The rename event will fire, and you can do Task2 after that.

--
William Stacey [MVP]

| Hi group,
|
| I have created a very simple application to test the FileSystemWatcher.
| It is great !
| I get all the event possible.
|
| but i need to make an operation AFTER a file is written, the
| FileSystemWatcher must detect the end of a writting operation on a
| file, and then call to the operation.
|
| if i use the 'created' event with a big file, the operation is starting
| before the end of writing the file.
| if i use the 'changed' event i get a number of event depending on the
| size of the file, or a single event on the file creation.
|
| how can i detect the end of a writing operation ?
| and what are the good System.IO.NotifyFilters combinaison for achieve
| it ?
|
| thank you
| ROM
|
 

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