class Program { static void Main(string[] args) { //TestReadCsv(); TestWriteCsv(); Console.ReadLine(); } static void TestWriteCsv() { using (FileStream fileStream = new FileStream("comment_1.csv", FileMode.OpenOrCreate, FileAccess.Write)) using (StreamWriter reader = new StreamWriter(fileStream, Encoding.GetEncoding("GBK"))) using (CsvWriter csv = new CsvWriter(reader)) { Comment com = new Comment(); com.id = "100"; com.iid = "1000"; com.Content = "hasfsfasdf,,,,,,,,,,,,,,,,,,,,..........,,,,,,,,,ha"; List<Comment> list = new List<Comment>(); list.Add(com); csv.WriteRecords<Comment>(list); } } static void TestReadCsv() { using (FileStream fileStream = new FileStream("comment.csv", FileMode.Open, FileAccess.Read)) using (StreamReader reader = new StreamReader(fileStream, Encoding.GetEncoding("GBK"))) using (CsvReader csv = new CsvReader(reader)) { csv.Read(); var content = csv.GetRecords<Comment>(); } } }