Example #1
0
        public static void ExportTranslationToCSV(string path)
        {
            try
            {
                if (!File.Exists(path))
                {
                    File.Create(path).Close();
                }

                var toExport = En.Select(kv => new TranslationCSV
                {
                    En  = kv.Value,
                    Key = kv.Key,
                    Fr  = Fr.ContainsKey(kv.Key) ? Fr[kv.Key] : string.Empty
                }).ToList();

                using (var writer = new StreamWriter(new FileStream(path, FileMode.Open, FileAccess.ReadWrite),
                                                     Encoding.UTF8))
                    using (var csv = new CsvWriter(writer))
                    {
                        csv.WriteRecords(toExport);
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while exporting: " + ex.Message);
            }
        }