c# - How to remove trailing empty lines in FileHelper -


thought easy, cannot find methods in filehelpengine remove trailing empty lines in text or csv file, causes readfile fail.

if number of empty lines known, example 2, can use in record class:

[ignorelast(2)] public class ... 

another option ignore empty lines ignored in place appear

[ignoreemptylines()] public class ... 

the last thing can try ignore lines code using inotifyread interface like:

[fixedlengthrecord(fixedmode.allowvariablelength)] [ignoreemptylines] public class ordersfixed     :inotifyread {    [fieldfixedlength(7)]    public int orderid;     [fieldfixedlength(8)]    public string customerid;     [fieldfixedlength(8)]    public datetime orderdate;     [fieldfixedlength(11)]    public decimal freight;     public void beforeread(beforereadeventargs e)   {     if (e.recordline.startswith(" ") ||        e.recordline.startswith("-"))         e.skipthisrecord = true;   }    public void afterread(afterreadeventargs e)   {        //  want drop records no freight     if (freight == 0)         e.skipthisrecord = true;    }  } 

Comments

Popular posts from this blog

java - Could not retrieve pre-bound Hibernate session - Could not obtain transaction-synchronized Session for current thread -

java - ConcurrentModificationException upon committing transaction with Hibernate -

java - Not entering the success part of http response in angularjs using spring mvc -