Re: Checking for Modification to a Set of Files
- From: ArkGunSlinger@xxxxxxxxxxx
- Date: 24 Mar 2006 06:00:39 -0800
Logan Shaw wrote
I'm not a Dot Net expert, but from the name of the function (or
class or facility or whatever it is), I am assuming this is one
of those systems where you can request to be automatically
notified when certain changes to the filesystem take place.
That means without polling. Which would mean that, while it's
not portable, it is technically superior to anything that would
be completely portable.
Yep!
Randy Howard wrote
Because it isn't standard. If I have a choice between using
SomeWindowsApiMagicCrapThatTakesFourhundredArguments()
Au Contraire! my friend, System.IO.FileSystemWatcher is part of the Dot
Net framework
not some "APIMagicCrap" and would be the standard for windows
programming for this particular
function.
// C#
// This needs to be declared in a place where it will not go out of
scope.
// For example, it would be a class variable in a form class.
System.IO.FileSystemWatcher MyWatcher = new
System.IO.FileSystemWatcher();
// This code would go in one of the initialization methods of the
class.
MyWatcher.Path = "c:\\";
// Watch only for changes to *.txt files.
MyWatcher.Filter = "*.txt";
MyWatcher.IncludeSubdirectories = false;
// Enable the component to begin watching for changes.
MyWatcher.EnableRaisingEvents = true;
// Filter for Last Write changes.
MyWatcher.NotifyFilter = System.IO.NotifyFilters.LastWrite;
// Example of watching more than one type of change.
MyWatcher.NotifyFilter =
System.IO.NotifyFilters.LastWrite | System.IO.NotifyFilters.Size;
You would of course need an event handler to do your thing when
notified of a change.
The same can be done in VB Dot Net just as easily.
I think you can download the VB or C# 2005 express versions for free.
Hey I'm not a MS employee or trying to "Convert" anyone I just thought
since the OP was
in the windows environment it seems like a reasonable suggestion!
later
.
- Follow-Ups:
- Re: Checking for Modification to a Set of Files
- From: Randy Howard
- Re: Checking for Modification to a Set of Files
- From: CBFalconer
- Re: Checking for Modification to a Set of Files
- References:
- Checking for Modification to a Set of Files
- From: mwmiller314
- Re: Checking for Modification to a Set of Files
- From: CBFalconer
- Re: Checking for Modification to a Set of Files
- From: crouch_dave
- Re: Checking for Modification to a Set of Files
- From: Randy Howard
- Re: Checking for Modification to a Set of Files
- From: Logan Shaw
- Checking for Modification to a Set of Files
- Prev by Date: Re: looping in c language
- Next by Date: Re: Software product activation solution
- Previous by thread: Re: Checking for Modification to a Set of Files
- Next by thread: Re: Checking for Modification to a Set of Files
- Index(es):
Relevant Pages
|