Esempio n. 1
0
        public void ExportHTMLDifferentFiles(string path)
        {
            var dayMessages = new Dictionary <DateTime, List <Msg> >();
            var msgs        = GetMessages();

            foreach (var msg in msgs)
            {
                var date = new DateTime(msg.Date.Year, msg.Date.Month, msg.Date.Day);
                if (!dayMessages.ContainsKey(date))
                {
                    dayMessages.Add(date, new List <Msg>());
                }

                dayMessages[date].Add(msg);
            }

            var name = Path.GetFileNameWithoutExtension(path);
            var dir  = Path.Combine(Path.GetDirectoryName(path), name);
            var ext  = Path.GetExtension(path);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            foreach (var dayMsg in dayMessages)
            {
                File.WriteAllText(Path.Combine(dir, name + "_" + dayMsg.Key.ToString("yyyy.MM.dd")
                                               + ext), HTMLExporter.GenerateHTML(Title, dayMsg.Value), Encoding.UTF8);
            }
        }
Esempio n. 2
0
        public void ExportHTML(string path)
        {
            var dir = Path.GetDirectoryName(path);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            File.WriteAllText(path, HTMLExporter.GenerateHTML(Title, GetMessages().ToList()), Encoding.UTF8);
        }