VB 最快速度写入二进制文件

来源:百度知道 编辑:UC知道 时间:2024/05/04 04:47:10
RT

Private Sub PutFileText(ByVal FileName As String, ByVal PutTxt As String, Optional Append As Boolean = False)
Dim tmpFileNum As Integer
tmpFileNum = FreeFile()
If Append Then
Open FileName For Binary As #tmpFileNum
If Dir(FileName) <> "" Then
If FileLen(FileName) <> 0 Then
Seek (tmpFileNum), LOF(tmpFileNum) + 1
PutTxt = vbCrLf & PutTxt
End If
End If
Put #tmpFileNum, , PutTxt
Close #tmpFileNum
Else
If Dir(FileName) <> "" Then
If FileLen(FileName) > LenB(PutTxt) Then
Kill FileName
End If
End If
Open FileName For Binary As #tmpFileNum
Put #tmpFileNum, , PutTxt
Close #tmpFileNum
End If
End Sub

用法: