Skip to content

Commit

Permalink
initial code for watching directories
Browse files Browse the repository at this point in the history
  • Loading branch information
tiernano committed Jul 4, 2011
1 parent 3948d7a commit 4a0e1c5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions GitBuilder/Program.cs
Expand Up @@ -2,13 +2,44 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GitBuilder
{
class Program
{
static void Main(string[] args)
{
if (args.Count() > 0)
{
string directory = args[0];
if (Directory.Exists(directory))
{
using (FileSystemWatcher fw = new FileSystemWatcher(directory, "*.txt"))
{
fw.Created += new FileSystemEventHandler(fw_Created);
fw.EnableRaisingEvents = true;
Console.WriteLine("Watching {0}", directory);
Console.WriteLine("hit enter to kill");
Console.ReadLine();
}

}
else
{
Console.WriteLine("Directory does not exist... cant watch something that dont exist");
}
}
else
{
Console.WriteLine("Need param: Directory name to watch");
}
}

static void fw_Created(object sender, FileSystemEventArgs e)
{
Console.WriteLine("the file {0} was created", e.FullPath);
}

}
}

0 comments on commit 4a0e1c5

Please sign in to comment.