Re: Checking for Modification to a Set of Files
- From: Randy Howard <randyhoward@xxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Mar 2006 22:08:30 GMT
ArkGunSlinger@xxxxxxxxxxx wrote
(in article
<1143208838.990512.289910@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>):
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.
It's "APIMAgicCrap" from here, because I am running OS X. Be
sure and tell me how to get it to run on it. Same for my Linux
box, my FreeBSD system, and my Novell NetWare server.
// 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.
Can you post a link to the free download for OS X please?
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!
It probably is, if he wants a windows-specific solution.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
.
- Follow-Ups:
- Re: Checking for Modification to a Set of Files
- From: Ben Bacarisse
- 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
- Re: Checking for Modification to a Set of Files
- From: ArkGunSlinger
- Checking for Modification to a Set of Files
- Prev by Date: Re: find a number
- Next by Date: Re: Checking for Modification to a Set of Files
- 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
|