K
Krish
Hello Gurus,
Pardon me for asking dumb question...
I wrote small csharp program to watch a folder for any created text file...
When i try to run through debugger and stop after "
watcher.EnableRaisingEvents = true;", i manually drag and drop windows text
file and this program doesnt seem to fire up... see code below and pl.
advise what wrong iam doing. Thanks.
public static void Main ()
{
Run();
}
public static void Run()
{
string FilePath = "D:\\BECSolution\\Jobs\\Faster\\bin\\Debug";
Console.WriteLine("File Monitoring Started");
Console.WriteLine("\t{0} is being monitored", FilePath);
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = FilePath;
watcher.NotifyFilter = NotifyFilters.FileName |
NotifyFilters.CreationTime;
watcher.Filter = "*.txt";
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
}
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
Pardon me for asking dumb question...
I wrote small csharp program to watch a folder for any created text file...
When i try to run through debugger and stop after "
watcher.EnableRaisingEvents = true;", i manually drag and drop windows text
file and this program doesnt seem to fire up... see code below and pl.
advise what wrong iam doing. Thanks.
public static void Main ()
{
Run();
}
public static void Run()
{
string FilePath = "D:\\BECSolution\\Jobs\\Faster\\bin\\Debug";
Console.WriteLine("File Monitoring Started");
Console.WriteLine("\t{0} is being monitored", FilePath);
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = FilePath;
watcher.NotifyFilter = NotifyFilters.FileName |
NotifyFilters.CreationTime;
watcher.Filter = "*.txt";
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
}
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}