Windows サービスのディレクトリ内のファイルを常に読み取るための優れたソリューションを探しています。現在、FileSystemWatcher を使用して、ディレクトリに追加される xml ファイルを処理しています。これは、サービスの実行中にうまく機能します。ただし、何らかの理由でサービスが停止した場合、サービスの停止中にディレクトリに追加されたファイルは処理されません。考えられる最善の解決策は何ですか?以下は、FileSystemWatcher のコードです。おそらく FileSystemWatcher はこれを行うことができますが、間違って使用している可能性があります。
// Setup FileSystemWatcher to watch 'IN' directory...
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = ConfigurationManager.AppSettings["InputPath"];
watcher.EnableRaisingEvents = true;
watcher.Filter = "*.xml";
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName;
watcher.Created += new FileSystemEventHandler(FileAdded);