'adodb.Stream读文本文件
Private Sub Command1_Click()
Dim myData() As Byte
myFile = "c:/VRLServer.txt"
Dim adoSrm As Object
Set adoSrm = CreateObject("adodb.Stream")
adoSrm.Mode = 3
adoSrm.Type = 2
adoSrm.Charset = "GB2312"
adoSrm.Open
adoSrm.LoadFromFile (myFile)
myData = adoSrm.ReadText
Print myData
adoSrm.Close
End Sub
'adodb.Stream'读写二进制文件
Private Sub Command5_Click()
Dim myFile, myFile1 As String
myFile = "c:/winnt.bmp" '源文件
myFile1 = "c:/winnt1.bmp" '目标文件
Dim adoSrm As Object
Set adoSrm = CreateObject("adodb.Stream")
adoSrm.Mode = 3
adoSrm.Type = 1
adoSrm.Open
adoSrm.LoadFromFile (myFile)
adoSrm.Read
adoSrm.SaveToFile (myFile1)
adoSrm.Close
End Sub
'VB+adodb.Stream读写二进制文件
Private Sub Command2_Click()
Dim myData() As Byte
Dim myFile, myFile1 As String
myFile = "c:/winnt.bmp" '源文件
myFile1 = "c:/winnt(备份).bmp" '目标文件
Dim adoSrm As Object
Set adoSrm = CreateObject("adodb.Stream")
adoSrm.Mode = 3
adoSrm.Type = 1
adoSrm.Open
adoSrm.LoadFromFile (myFile)
myData = adoSrm.Read
adoSrm.Close
Dim myData1() As Byte
Open myFile1 For Binary As #1
Put #1, 1, myData
Close #1
End Sub