The VB6 Line Input keyword reads a string from an open file until it finds either a CR-LF pair (ASCII 13 + ASCII 10) or a single CR (ASCII 13) character. The corresponding FileLineInput VB.NET function requires that each line be terminated with a CR-LF pair and ignores single CR characters.
VB Migration Partner converts Line Input statements into calls to the FileLineInput6 helper method (defined in CodeArchitects.VBLibrary.Dll), which in turn is based on VB.NET FileLineInput method and therefore inherits the abovementioned behavior.
As a result, if the file being read uses single CR characters as line delimiters, such a file can’t be read correctly from inside a migrated VB.NET project. There are a number of workarounds:
- First, if possible modify the structure of the text file to use CR-LF pairs as line separators. (This isn’t an option if the file is generated by another application.)
- If the file isn’t too large, use the File.ReadAllText method to read it in memory in one operation, then use the String.Split method to extract individual lines. The benefit of this technique is that the file read operation is faster.
- Define a method in your project named FileLineInput6 so that it overrides the method inside CodeArchitects.VBLibrary DLL. Such custom method should read from file one character at a time, and return a line as soon as a CR character is found.