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 exception due to this. All other lines have proper fixed width. How to skipt first and last lines or other way to read data without exception ?
[FixedLengthRecord()]
class Bank
{
[FieldFixedLength(4)]
public string AINETUNNUS;
[FieldFixedLength(16)]
public string TEKST1;
[FieldFixedLength(3)]
public string opliik;
[FieldFixedLength(2)]
public string hinnalis;
};
[AcceptVerbs(HttpVerbs.Post)]
[Authorize]
public ActionResult LoadStatement(HttpPostedFileBase uploadFile)
{
FileHelperEngine engine = new FileHelperEngine(typeof(Bank));
var res = engine.ReadStream(new StreamReader(uploadFile.InputStream,
Encoding.GetEncoding(1257))) as Bank[];
}