示例#1
0
        void AddFileWatcher(LogFileInfo info)
        {
            var directoryName = Path.GetDirectoryName(info.File.FullName);

            if (directoryName != null)
            {
                var fileSystemWatcher = new FileSystemWatcher(directoryName)
                {
                    Filter = info.File.Name
                };
                fileSystemWatcher.Changed += LogFileChanged;
                fileSystemWatcher.Deleted += LogFileChanged;
                fileSystemWatcher.Created += LogFileChanged;
                fileSystemWatcher.Error   += (sender, args) =>
                {
                    Console.WriteLine("Error");
                };
                fileSystemWatcher.NotifyFilter          = fileSystemWatcher.NotifyFilter | NotifyFilters.Size;
                info.FileSystemWatcher                  = fileSystemWatcher;
                fileSystemWatcher.EnableRaisingEvents   = true;
                fileSystemWatcher.IncludeSubdirectories = false;
            }
        }
示例#2
0
        void RemoveFileItems(LogFileInfo info)
        {
            var fileName = info.File.Name;

            m_AllItems.RemoveAll(item => (item.Filename == fileName));
        }