Windows service to open folder
-
Hi all, I have using FileSystemWatcher class so as to watch particular folder. If any new files get copied to it, windows explorer open the folder automatically. It works fine with console application but when it's been created as a windows service, it doesn't work. The code ---
public class JobClass
{
public void startJob()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Filter = "*.*";
watcher.Path = "c:\\DMSTemp";
watcher.EnableRaisingEvents = true;
watcher.Created +=new FileSystemEventHandler(watcher_Created);
Console.ReadLine();} void watcher\_Created(object sender, FileSystemEventArgs e) { Process process = new Process(); process.StartInfo.FileName = "explorer.exe"; process.StartInfo.CreateNoWindow = true; process.StartInfo.Arguments = "c:\\\\DMSTemp"; process.Start(); } }
From the onStart() event of WindowsService, JobClass's startJob method is invoked.
protected override void OnStart(string[] args)
{
JobClass jobClass = new JobClass();
jobClass.startJob();}
Any idea? Thanks, milan
satan