FileSystemWatcher: How to distinguish between different change eve

K

Klaus Gollin

Hi,

I am using FileSystemWatcher like this:

fsw = New IO.FileSystemWatcher(strPath, strFilename)
fsw.NotifyFilter = NotifyFilters.Size or NotifyFilters.LastWrite
fsw.EnableRaisingEvents = True

This raises two events when saving file.

Saving changes with notepad with or _without_ changing in size also raises
two times.

Using

fsw.NotifyFilter = NotifyFilters.Size

doesn't raise the change event, wenn saving, but not changing size.

Is there a way to find out, whether size has changed and/or date/time has
changed?

Thanks in advance

Klaus
 
C

coolCoder

Hi,

I am using FileSystemWatcher like this:

fsw = New IO.FileSystemWatcher(strPath, strFilename)
fsw.NotifyFilter = NotifyFilters.Size or NotifyFilters.LastWrite
fsw.EnableRaisingEvents = True

This raises two events when saving file.

Saving changes with notepad with or _without_ changing in size also raises
two times.

Using

fsw.NotifyFilter = NotifyFilters.Size

doesn't raise the change event, wenn saving, but not changing size.

Is there a way to find out, whether size has changed and/or date/time has
changed?

Thanks in advance

Klaus

Just check the Event arguments of the change event. Therein, I think,
is an Enum which specifies the type of change.
 
K

Klaus Gollin

Thanks for your answer
Just check the Event arguments of the change event. Therein, I think,
is an Enum which specifies the type of change.

That is the problem: debugging the event argument always shows "Change {4}"

Some other ideas?

Klaus
 
K

Klaus Gollin

Hi,

thanks for the links but those I already know. The examples are always the
same (and by the way also the ones translated to German), they only handling
the change event without going too deep.

May be someone has a internet source that describes this component more than
scratching on the surface.

Klaus
 

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