January 08, 2005

Using filesystemwatcher

I desperately needed to find out where Adobe Photoshop Album 2.0 stores its database files (damn software that doesn't allow configuring this!). Well, a quick search of the obvious places didn't reveal a thing, so I wrote a few lines of code to monitor the files being accessed. The following code is a trivial console program to monitor what's going on in your C: drive. Don't you just love the ease of .NET?

using System;
using System.IO;

namespace fswatchtest
{
class Program
{
  static void Main(string[] args)
  {
    FileSystemWatcher fswC = new FileSystemWatcher(@"c:\");
    fswC.IncludeSubdirectories = true;
    fswC.Changed += new FileSystemEventHandler(fsw_Changed);
    fswC.EnableRaisingEvents = true;
    Console.ReadLine();
  }

  static void fsw_Changed(object sender, FileSystemEventArgs e)
  {
    Console.WriteLine(e.FullPath);
  }

}

}
Posted by Jouni Heikniemi at January 8, 2005 06:52 PM
.net
Comments

Actually the ease of which it creates bugs or the number of workarounds needed is even more amazing. Try creating a FileSystemWatcher that uses a filter to look at a specific file. Then watch for changes. You don't get one event for any change to your file. You get multiple. That's great! Open up the file and write to it once and you get two events. Use Textpad to change the file and you get four events.

Very lame!

Posted by: Xanthros at January 11, 2006 07:45 PM

Agree with Xanthros, when you drop a big file in teh folder , the created event fires when the file is zero bytes and again when it is finished copying, and you can;t tell which is which

Posted by: Ant at March 29, 2006 11:20 AM

9gh7Ko 1800flowers [url]http://1800flowers.bloges.org/[/url] [url=http://1800flowers.bloges.org/]http://1800flowers.bloges.org/[/url] http://1800flowers.bloges.org/
[link]http://1800flowers.bloges.org/[/link]

Posted by: 1800 at June 30, 2008 11:50 AM

Ighoyrsgyesnycd [url]http://ndulmi9zji.tripod.com[/url] vdmmvj [url=http://ndulmi9zji.tripod.com]http://ndulmi9zji.tripod.com[/url] yllzziuyqeeyv http://ndulmi9zji.tripod.com dtawgyzkatnmfi [link]http://ndulmi9zji.tripod.com[/link]

Posted by: Alex at July 1, 2008 09:59 PM

Zzvahndcfp [url]http://owakhwm1az.tripod.com[/url] fzotzpwewkfmzg [url=http://owakhwm1az.tripod.com]http://owakhwm1az.tripod.com[/url] mjtowsmrstdwwjk http://owakhwm1az.tripod.com ojgghwcmrmsd [link]http://owakhwm1az.tripod.com[/link]

Posted by: Verity at July 1, 2008 10:42 PM
Post a comment









Remember personal info?