这是在VB6中逐行加载整个文件的最快方法:
Function FileText (filename$) As String
Dim handle As Integer
handle = FreeFile
Open filename$ For Input As #handle
FileText = Input$(LOF(handle), handle)
Close #handle
End Function
Run Code Online (Sandbox Code Playgroud)
Public Function ReadFileIntoString(strFilePath As String) As String
Dim fso As New FileSystemObject
Dim ts As TextStream
Set ts = fso.OpenTextFile(strFilePath)
ReadFileIntoString = ts.ReadAll
End Function
Run Code Online (Sandbox Code Playgroud)