private static int Main(string[] args) { int retValue = -1; try { SetupStaticLogger(); ChatHistory chatConversations = null; var convCounter = 0; retValue = ParseArgs(args); if (retValue != 0) { return(retValue); } var inFile = new FileInfo(jsonPath); var inDir = inFile.Directory; if (!inDir.Exists) { Log.Warning($"The directory specified does not exist. The program cannot continue: {inDir.FullName}"); return(1); } else if (!inFile.Exists) { Log.Warning($"The file specified does not exist. The program cannot continue: {inDir.FullName}"); return(1); } Log.Information($"Attempting to read {jsonPath}. This may take a few minutes."); var regex = new Regex(@"^ROOT.conversations\[\d+\].conversation$"); using (FileStream s = File.Open(jsonPath, FileMode.Open)) using (StreamReader sr = new StreamReader(s)) using (JsonReader reader = new JsonTextReader(sr)) { reader.SupportMultipleContent = true; var serializer = new JsonSerializer(); while (reader.Read()) { if (reader.TokenType == JsonToken.StartObject) { convCounter++; chatConversations = serializer.Deserialize <ChatHistory>(reader); Log.Information($"Found {chatConversations?.conversations?.Length} conversations to process"); } } } DirectoryInfo outputDir = new DirectoryInfo($".{Path.DirectorySeparatorChar}Output"); IFormatExporter exporter = new HTMLExporter(); exporter.Generate(chatConversations, outputDir); return(retValue); } catch (Exception ex) { Log.Error(ex, $"An unhandled exception has occurred. Details follow."); return(-1); } finally { Log.CloseAndFlush(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }