Я хочу отслеживать некоторые каталоги, используя FileSystemWatcher, но FileSystemWatcher.created вообще не работает.
CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Configuration;
using System.Threading;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static string fileName;
static string dirFileName;
static void Main(string[] args)
{
string _Dir = ConfigurationManager.AppSettings["Dir"];
Console.WriteLine("MAIDProcessFileTest processing started");
FileSystemWatcher _watch = new FileSystemWatcher();
_watch.Path = _Dir;
_watch.Created += FileCreated;
Console.ReadLine();
}
private static void FileCreated(object sender, FileSystemEventArgs e)
{
Console.WriteLine("Before is treat");
fileName = Path.GetFileName(e.FullPath);
dirFileName = Path.GetDirectoryName(e.FullPath) + @"\" + Path.GetFileName(e.FullPath);
}
}
}
Может кто-нибудь сказать мне, почему этот код не работает ... всякий раз, когда я отлаживаю _watch.Created + = FileCreated;не работает вообще.где ошибка может кто-нибудь сказать мне.Пожалуйста, помогите