Re: Checking for Modification to a Set of Files



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





.



Relevant Pages

  • Re: Computer shuts down by itself..?
    ... > I currently have Windows XP Home SP2. ... > closing alot of pages, and or watching a clip of something, it seems as ... > so opening and closing the pages while watching something is no big deal ...
    (microsoft.public.windowsxp.accessibility)
  • Re: framerates
    ... "I get tired of repeating myself, so I sit back and have a good belly laugh ... > Windows users that have been screwed up because of the shitty security ... > sit back and have a good belly laugh watching them. ... > himself under a garbage bin when challenged to report me for real. ...
    (alt.os.linux)
  • Re: Windows 7
    ... Are you another Windows user who's afraid to go to You Tube and see how cool Ubuntu is and how Windows isn't? ... Course, you stopped watching it as soon as you saw the intro which, indeed, and old video of the Monkey Man. ... You do realize that everyone in here hates your lying linux guts right? ...
    (microsoft.public.windows.vista.general)
  • please help!
    ... >every time I log into windows a small windows pops up ... >.Sounds like you have got spyware on your pc. ... Destroy" onto my computer.It's a free download, ... left click on "Properties" and an Internet Properties ...
    (microsoft.public.windowsxp.general)
  • Re: Video "softness"/compression on TV
    ... You can view Recorded TV using Windows Media Player. ... Of course I was watching straight TV, not throught the PVR feature of windows. ... The video looks good playing from a DVD on your TV ...
    (microsoft.public.windows.mediacenter)