예제 #1
0
        public FileWatcher(string fileName)
        {
            ++instanceCount;

            this.fileName           = Path.GetFullPath(fileName);
            fsw                     = new FileSystemWatcher(Path.GetDirectoryName(this.fileName), Path.GetFileName(this.fileName));
            fsw.NotifyFilter        = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size;
            fsw.Changed            += Fsw_Changed;
            fsw.Created            += Fsw_Created;
            fsw.Deleted            += Fsw_Deleted;
            fsw.Renamed            += Fsw_Renamed;
            fsw.Error              += Fsw_Error;
            fsw.EnableRaisingEvents = true;

            fc          = new FileChecker(this.fileName, new TimeSpan(0, 0, 0, 0, 10));
            fc.Changed += Fsw_Changed;
            fc.Start();
        }