FileHelpers: How to skip first and last line reading fixed width text

前端 未结 3 878
无人共我
无人共我 2021-02-19 02:31

Code below is used to read fixed width uploaded file content text file using FileHelpers in ASP .NET MVC2

First and last line lengths are smaller and ReadStream causes e

3条回答
  •  滥情空心
    2021-02-19 02:50

    the best is to decorate your class with the [IgnoreFirst] attribute.

    If for some reason you can't add the attribute you can do something like this

    var engine = new FileHelperEngine();
    engine.BeforeReadRecord += (e, args) =>
    {
        if (args.LineNumber == 1)
            args.SkipThisRecord = true;
    };
    

提交回复
热议问题