C#windowservice文件观察器只接收第一个文件

时间:2016-09-19 11:02:22

标签: c# windows-services

我在Window Service中遇到FileWatcher问题。我设置了由fileWatcher监视的传入文件夹,但它只需要第一个文件。当我粘贴到文件夹新文件时,没有任何事情发生。 来人帮帮我?请

namespace Equalizer_Service
{
    public partial class Service1 : ServiceBase
    {
        static void Main()
        {
            ServiceBase.Run(new Service1());
        }

        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            fileSystemWatcher1.Path = ConfigurationManager.AppSettings["WatchPath"];
            Library.WriteErrorLog("Window service was started");
        }

        protected override void OnStop()
        {
            Library.WriteErrorLog("Window service was stopped");
        }

        private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            GetPaths.getPaths();
            GenerateXML.generateXML();
            Excel_Chart.KillExcel();
            Library.WriteErrorLog("Job was done after file was changed");
        }

        private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            GetPaths.getPaths();
            GenerateXML.generateXML();
            Excel_Chart.KillExcel();
            Library.WriteErrorLog("Job was done after new request was added");

        }
    }
}

0 个答案:

没有答案