Example #1
0
        private void BtnSaveCsv_Click(object sender, EventArgs e)
        {
            if (_candidateList == null)
            {
                AppendLogBox("Empty candidate list");
                return;
            }
            if (_candidateList.Count == 0)
            {
                AppendLogBox("No candidates in list");
                return;
            }

            var dummy = new Candidate();

            var sb = new StringBuilder();

            sb.AppendLine(dummy.CsvHeader());

            foreach (var candidate in _candidateList)
            {
                sb.AppendLine(candidate.ToCsv());
            }

            var path = $"{tbCsvFilePath.Text}\\{Utils.FilenameWithDateTime("CandidatesEthics", "csv")}";

            FileHelper.StringToFile(sb, path);

            AppendLogBox($"CSV file written to {path}");
        }