Exemple #1
0
        public void WriteComment(params string[] comments)
        {
            if (comments == null || comments.Length == 0)
            {
                return;
            }

            var configuration = GetConfiguration();

            using (var writer = new CsvHelper.CsvWriter(TextWriter, configuration))
            {
                foreach (var comment in comments)
                {
                    writer.WriteComment(comment);
                    writer.NextRecord();
                }
            }
        }
Exemple #2
0
        public bool writetofile(string query)
        {
            using (var textwriter = new StreamWriter(query))

            {
                try
                {
                    if (winners.Count > 0)
                    {
                        var writer = new CsvHelper.CsvWriter(textwriter, false);
                        writer.Configuration.Delimiter = ",";

                        writer.WriteComment("This draw name is " + drawname + " ." + "Draw Dated on " + DateTime.Now.ToString());
                        writer.NextRecord();
                        writer.WriteHeader <KeyValuePair <int, string> >();
                        writer.NextRecord();

                        foreach (var item in winners)
                        {
                            writer.WriteField(item.Key);
                            writer.WriteField(item.Value);
                            writer.NextRecord();
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }