A
Aaron
I tried this with and without a timer, I got farther with a timer. THis code
works just fine in a form but only gets as far as activating StartWatcher in
the Win Service.
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
//timer2.Start();
StartWatcher();
EventLog.WriteEntry("OnStart","OnStart activated");
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your
service.
timer2.Stop();
EventLog.WriteEntry("OnStop","OnStop activated");
}
private void StartWatcher()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"C:\input";
watcher.Filter = "*.txt";
// Add event handlers.
watcher.EnableRaisingEvents = true;
watcher.Created +=new FileSystemEventHandler(watcher_Created);
//it creates this entry in the log and thats it, when i drop the file it
doesn't pick up
EventLog.WriteEntry("StartWatcher","StartWatcher activated - next
watcher_Created");
}
private void watcher_Created(object sender, FileSystemEventArgs e)
{
//write some code here to pick up the files
ProcessFile();
EventLog.WriteEntry("watcher_Created","watcher_Created activated - File
dropped");
}
private void ProcessFile()
{
//code to process file
EventLog.WriteEntry("ProcessFile","ProcessFile activated");
}
private void timer2_elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//not using this now
//active StartWatcher
StartWatcher();
EventLog.WriteEntry("timer2_elapsed","timer2_elapsed activated - next
startwatcher");
}
I just don't see what is wrong?
works just fine in a form but only gets as far as activating StartWatcher in
the Win Service.
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
//timer2.Start();
StartWatcher();
EventLog.WriteEntry("OnStart","OnStart activated");
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your
service.
timer2.Stop();
EventLog.WriteEntry("OnStop","OnStop activated");
}
private void StartWatcher()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"C:\input";
watcher.Filter = "*.txt";
// Add event handlers.
watcher.EnableRaisingEvents = true;
watcher.Created +=new FileSystemEventHandler(watcher_Created);
//it creates this entry in the log and thats it, when i drop the file it
doesn't pick up
EventLog.WriteEntry("StartWatcher","StartWatcher activated - next
watcher_Created");
}
private void watcher_Created(object sender, FileSystemEventArgs e)
{
//write some code here to pick up the files
ProcessFile();
EventLog.WriteEntry("watcher_Created","watcher_Created activated - File
dropped");
}
private void ProcessFile()
{
//code to process file
EventLog.WriteEntry("ProcessFile","ProcessFile activated");
}
private void timer2_elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//not using this now
//active StartWatcher
StartWatcher();
EventLog.WriteEntry("timer2_elapsed","timer2_elapsed activated - next
startwatcher");
}
I just don't see what is wrong?