Example #1
0
        public LogFileResults Analyze(string logFilePath)
        {
            using (var stream = new FileStream(logFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
                using (var reader = new StreamReader(stream, true))
                {
                    var results = new LogFileResults();
                    results.FilePath = logFilePath;

                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        foreach (var c in line)
                        {
                            results.CharacterFrequencies.Add(c);
                        }
                        results.LineCount++;
                        results.LineLengths.Add(line.Length);
                    }

                    results.Encoding = reader.CurrentEncoding.EncodingName;
                    LineLengths.Add(results.LineLengths);
                    CharacterFrequencies.Add(results.CharacterFrequencies);

                    return(results);
                }
        }
Example #2
0
        public LogFileResults Analyze(string logFilePath)
        {
            using (var stream = new FileStream(logFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
            using (var reader = new StreamReader(stream, true))
            {
                var results = new LogFileResults();
                results.FilePath = logFilePath;

                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    foreach (var c in line)
                    {
                        results.CharacterFrequencies.Add(c);
                    }
                    results.LineCount++;
                    results.LineLengths.Add(line.Length);
                }

                results.Encoding = reader.CurrentEncoding.EncodingName;
                LineLengths.Add(results.LineLengths);
                CharacterFrequencies.Add(results.CharacterFrequencies);

                return results;
            }
        }