ADO DOT NET
Centurion
- Joined
- Dec 20, 2006
- Messages
- 160
I use this code to read and split the first line of a text file:
But in MSDN I red that:
The FileOpen function is provided for backward compatibility and may affect performance. For non-legacy applications, the My.Computer.FileSystem object provides better performance.
-
I also found this example:
The problem is that I cannot read just the first line of text file using new method.
Also how can I close the file after reading?
Thank you for your help
Visual Basic:
Dim LineIn As String
Dim SStr() As String
FileOpen(1, ("c:\file.txt"), OpenMode.Input)
LineIn = LineInput(1)
SStr = LineIn.Split(vbTab)
FileClose(1)
The FileOpen function is provided for backward compatibility and may affect performance. For non-legacy applications, the My.Computer.FileSystem object provides better performance.
-
I also found this example:
Visual Basic:
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt")
MsgBox(fileReader)
Also how can I close the file after reading?
Thank you for your help