Using CSVHelper on file upload

后端 未结 2 1220
傲寒
傲寒 2021-01-04 12:54

I am trying to use the CSVhelper plugin to read an uploaded CSV file. Here is my modelBinder class:

public class SurveyEmailListModelsModelBinder : DefaultMo         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 13:20

    I had similar issue , but sorted out, when I tried the below code

    void Main()
    {
        using (var reader = new StreamReader("path\\to\\file.csv"))
        using (var csv = new CsvReader(reader, 
               System.Globalization.CultureInfo.CreateSpecificCulture("enUS")))
        {
            var records = csv.GetRecords();
        }
    }
    

    Please note below code wont work with latest versions of CSV Helper

    using (var csvReader = new CsvReader(reader))
    

提交回复
热议问题