Invoke method fails when using TextFieldParser

I am trying to convert a fixed length textfile to datatable.

This the vb code I am trying to use:

VB

Using MyReader As New Microsoft.VisualBasic.FileIO. TextFieldParser(“C:\ParserText.txt”) MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.FixedWidth MyReader.FieldWidths = {5, 10, 11, -1}

I am getting error when using invoke method for this code:

MyReader.FieldWidths = {5, 10, 11, -1}

Any help please.

1 Like

Hi @pravinraj.vincent ,

Could you share more details on the error message that you observe? The code you posted seems to work on my machine (as long as two statements on last line are separated by newline)