说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB取得文件内容

HTML文档下载 WORD文档下载 PDF文档下载
VB取得文件内容
To read a complete file in VB, the normal procedure is to read the contents of the file line by line and accumulate it into a string. Instead, you can use the GET function to read the file with a single call. Doing so simplifies and speeds up the process of reading a file.

You can use the following function:


Dim Handle As Integer
Dim FileString As String
Handle = FreeFile
Open "C:\TEMP\TST.TXT" For Binary As #Handle
FileString = Space(FileLen("C:\TEMP\TST.TXT"))
Get #Handle, ,FileString
Close #Handle
This code involves a single call to return the contents of the file.
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘