using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.ServiceProcess;using System.IO;namespace FolderPollerService{ public partial class FolderPollerSrvc : ServiceBase { FileSystemWatcher[] watchers; public FolderPollerSrvc() { InitializeComponent(); } protected override void OnStart(string[] args) { // get the list of hot folders, let say from registry. string[] sFolders = //get the folder's path if (sFolders != null && sFolders .Length > 0) { watchers = new FileSystemWatcher[hotfolderInfo.Length]; for (int i = 0; i < hotfolderInfo.Length; i++) { watchers[i] = new FileSystemWatcher(); watchers[i].Path = sFolders [i]; watchers[i].NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; watchers[i].Filter = "*.mp3"; watchers[i].EnableRaisingEvents = true; watchers[i].Created += new FileSystemEventHandler(FSWatcher_Created); } } } void FSWatcher_Created(object sender, System.IO.FileSystemEventArgs e) { //put the file to user's favorite music folder } protected override void OnStop() { } }}