求教一个二进制方式打开文件的疑问
如何以二进制方式打开一个文件,并把文件的第一个字符串内容和最后一个字符串内容调换位置,并保存文件存放目录 c:\a2.bmp
求哪位好心人能给个思路或方法,谢谢了
Dim myByt() As Byte '定义一个数组 FileSize = FileLen(OldFile) '获取文件长度 ReDim myByt(FileSize - 1) As Byte Open OldFile For Binary As #1 Get #1, , myByt Close #1 Dim byt1 As Byte byt1 = myByt(LBound(myByt)) myByt(LBound(myByt)) = myByt(UBound(myByt)) myByt(UBound(myByt)) = byt1 Open NewFile For Binary As #2 Put #2, , myByt Close #2
Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim mst As New ADODB.Stream Private Sub List1_Click() Dim cnnstr As String cnnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\ABC.mdb;Persist Security Info=False" cn.Open cnnstr rs.Open "select * from 文件表 where 名称='" + List1.Text + "'", cn, adOpenDynamic, adLockOptimistic mst.Type = adTypeBinary mst.Open mst.Write rs.Fields("文件") mst.SaveToFile App.Path & "\doc\" & List1.Text & ".jpg", adSaveCreateOverWrite '在doc目录中存储图片 Image1.Picture = LoadPicture(App.Path & "\doc\" & List1.Text) '在 Image1 控件显示图片 mst.Close rs.Close End Sub