Re: Checking for Modification to a Set of Files



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

.



Relevant Pages

  • Re: ASP.NET Book, C#, no code-inside
    ... > been programming with winforms in .NET for a few years now. ... so jumping on the dot net framework the minute it ... > trying to get me to use the dot net framework 2.0. ... >> language and the new 'code-beside' partial class architecture as the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET Book, C#, no code-inside
    ... so jumping on the dot net framework the minute it goes ... I'm looking for a great ASP.NET book which uses C#, code-behind, and isn't ... trying to get me to use the dot net framework 2.0. ... > language and the new 'code-beside' partial class architecture as the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: VB6Twilighted --
    ... The .Net framework is going to be part of all future Microsoft OSs, ... Decompilation is by far my number one objection to ... > I'm also not happy with the fact that no dot net app can be run unless ... > the user downloads the 21 MB dot net framework. ...
    (microsoft.public.vb.general.discussion)
  • BITS and Visual Studio 6
    ... Does BITS (Background Intelligent Transfer Service) 1.5 require Dot ... Bits 2.0 needs the dot net framework but Bits 1.5 does not. ... Is the dot net framework required for using Bits on the client side? ...
    (microsoft.public.dotnet.languages.csharp)
  • Dot Net framework and Bits 1.5
    ... Does BITS (Background Intelligent Transfer Service) 1.5 require Dot ... Bits 2.0 needs the dot net framework but Bits 1.5 does not. ... Is the dot net framework required for using Bits on the client side? ...
    (microsoft.public.dotnet.framework.interop)