Example #1
0
        public void WriteAll(string file, List <KeyValuePair <string, int> > records)
        {
            Integrity.CheckFile(file);

            using (TextWriter textWriter = File.CreateText(file))
            {
                var csvWriter = new CsvWriter(textWriter);
                foreach (var item in records)
                {
                    csvWriter.WriteRecord(item);
                }
            }
        }
Example #2
0
        public List <Record> ReadAll(string file)
        {
            Integrity.CheckFile(file);

            try
            {
                using (var textReader = File.OpenText(file))
                {
                    return(new CsvReader(textReader).GetRecords <Record>().ToList());
                }
            }
            catch (FileNotFoundException fex)
            {
                throw fex;
            }
        }
Example #3
0
        public void WriteAll(string file, IOrderedEnumerable <KeyValuePair <string, string> > records)
        {
            Integrity.CheckFile(file);

            using (TextWriter textWriter = File.CreateText(file))
            {
                /*
                 * Turns out CsvWriter is buggy.
                 *
                 * var csv = new CsvWriter(textWriter);
                 * csv.WriteRecords(list);
                 */

                foreach (var record in records.ToList())
                {
                    if (record.Value != null)
                    {
                        textWriter.WriteLine(record.Value);
                    }
                }
            }
        }