FileSystem.InputString Method (Int32, Int32)
Returns String value that contains characters from a file opened in Input or Binary mode. The My feature gives you better productivity and performance in file I/O operations than InputString. For more information, see FileSystem.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Required. Any valid file number.
Required. Any valid numeric expression specifying the number of characters to read.
Return ValueType: System.String
Returns String value that contains characters from a file opened in Input or Binary mode. The My feature gives you better productivity and performance in file I/O operations than InputString.
The InputString function is provided for backward compatibility and may affect performance. For non-legacy applications, the My.Computer.FileSystem object provides better performance. For more information, see File Access with Visual Basic.
Data read with the InputString function is usually written to a file by using Print or FilePut. Use this function only with files opened in Input or Binary mode.
Unlike the Input function, the InputString function returns all the characters it reads. This includes commas, carriage returns, line feeds, quotation marks, and leading spaces.
With files opened for Binary access, an attempt to read through the file by using the InputString function until EOF returns True generates an error. Use the LOF and Loc functions instead of EOF when you read binary files by using InputString, or use FileGet when you use the EOF function.
When reading from files, do not make security decisions about the contents of the file based on the file name extension. For example, a file named Form1.vb may not be a Visual Basic source file.
This example uses the InputString function to read one character at a time from a file and print it to the Output window. This example assumes that MyFile is a text file that has several lines of sample data.
Available since 1.1