Just as an FYI, here's my code for something similar:
private void btnStartMonitoring_Click(object sender, EventArgs e)
{
System.IO.FileSystemWatcher fsw = new
FileSystemWatcher(txtDirectoryName.Text.ToString());
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite |
NotifyFilters.FileName | NotifyFilters.DirectoryName;
fsw.Filter = "*.cnk";
fsw.Created += new FileSystemEventHandler(OnCreated);
// Begin watching.
fsw.EnableRaisingEvents = true;
}
private static void OnCreated(object source, FileSystemEventArgs e)
{
string sMessage = "File: " + e.FullPath + " " + e.ChangeType;
MessageBox.Show(sMessage);
}
There is no loop monitoring the status; it simply fires when the event
occurs. Now one thing I'm still fighting with is that I need to Invoke the
process to happen afterwards, otherwise the UI does goofy things. See my
post from 04/08/06. But that's just tweaking...

Famous last words.
Clint
Frank said:
I figured it out. It seemes that the while loop is the fault. I changed the
while(true) to use Console.ReadLine() which helped.
using System.IO;
namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static bool bNew = false;
static void Main(string[] args)
{
FileSystemWatcher buildWatcher = new FileSystemWatcher();
buildWatcher.Path = "C:\\";
buildWatcher.NotifyFilter = NotifyFilters.LastWrite
| NotifyFilters.FileName;
buildWatcher.Filter = "myfile.txt";
buildWatcher.Changed += new FileSystemEventHandler(OnChanged);
while (true)
{
if (bNew)
{
//. something to do here
}
}
}
public static void OnChanged(object source, FileSystemEventArgs e)
{
bNew = true;
}
}
}