By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,397 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,397 IT Pros & Developers. It's quick & easy.

Detecting when a file has changed on disk?

P: n/a
In the absence of IAdviceSink support in .NET (well, not the pure vanilla
COM version anyway), I need to be able to tell when another process has
saved changes to a file, in a similar way some programs state "file has
changed on disk, reload?". I was wondering what strategy I should use in
order to check temp files I have created to see if they have been changed by
another process. My initial thought is to periodically check the files, but
if there are (say) 20 of them, this could in time become quite a drag on
performance.

Any other strategies I can use?
Robin
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cor
Robin,

There is a the filesystemwatcher class, I think that does what you ask.

This I copied from that class documentation

There are several types of changes you can watch for in a directory or file.
For example, you can watch for changes in Attributes, the LastWrite date and
time, or the Size of files or directories. This is done by setting the
FileSystemWatcher.NotifyFilter property to one of the NotifyFilters values.
For more information on the type of changes you can watch, see
NotifyFilters.

I hope this is something you mean?

Cor
In the absence of IAdviceSink support in .NET (well, not the pure vanilla
COM version anyway), I need to be able to tell when another process has
saved changes to a file, in a similar way some programs state "file has
changed on disk, reload?". I was wondering what strategy I should use in
order to check temp files I have created to see if they have been changed by another process. My initial thought is to periodically check the files, but if there are (say) 20 of them, this could in time become quite a drag on
performance.

Nov 20 '05 #2

P: n/a
Yes, I just found that - thanks anyway (its just what I want).

"Cor" <no*@non.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Robin,

There is a the filesystemwatcher class, I think that does what you ask.

This I copied from that class documentation

There are several types of changes you can watch for in a directory or file. For example, you can watch for changes in Attributes, the LastWrite date and time, or the Size of files or directories. This is done by setting the
FileSystemWatcher.NotifyFilter property to one of the NotifyFilters values. For more information on the type of changes you can watch, see
NotifyFilters.

I hope this is something you mean?

Cor
In the absence of IAdviceSink support in .NET (well, not the pure vanilla COM version anyway), I need to be able to tell when another process has
saved changes to a file, in a similar way some programs state "file has
changed on disk, reload?". I was wondering what strategy I should use in order to check temp files I have created to see if they have been
changed by
another process. My initial thought is to periodically check the files,

but
if there are (say) 20 of them, this could in time become quite a drag on
performance.


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.