Private Sub OpenFile(RsTmp As ADODB.Recordset, mTempDoc As String)
Dim buf() As Byte
Dim intFileId As Long
Dim intFileSize As Long
Dim I As Integer, J As Integer, K As Integer
On Error GoTo OpenErr
intFileId = FreeFile()
Open mTempDoc For Binary Access Write As #intFileId
intFileSize = RsTmp("mFile").ActualSize
I = intFileSize \ BLOCK_SIZE
J = intFileSize Mod BLOCK_SIZE
ReDim buf(I)
For K = 1 To I
buf() = RsTmp("mFile").GetChunk(BLOCK_SIZE)
Put #intFileId, , buf()
Next
If J <> 0 Then
ReDim buf(BLOCK_SIZE)
buf() = RsTmp("mFile").GetChunk(J)
Put #intFileId, , buf()
End If
Close #intFileId
Exit Sub
OpenErr:
MsgBox "Error! - " & Err.Description
Err.Clear
End Sub
mTempDoc 是指你要还原的文件的一个临时文件
例如:如果是jpg的图片,那么mtempdoc="c:\temp\temp.jpg"
如果是doc的文档,那么mtempdoc="c:\temp\temp.doc"
Dim buf() As Byte
Dim intFileId As Long
Dim intFileSize As Long
Dim I As Integer, J As Integer, K As Integer
On Error GoTo OpenErr
intFileId = FreeFile()
Open mTempDoc For Binary Access Write As #intFileId
intFileSize = RsTmp("mFile").ActualSize
I = intFileSize \ BLOCK_SIZE
J = intFileSize Mod BLOCK_SIZE
ReDim buf(I)
For K = 1 To I
buf() = RsTmp("mFile").GetChunk(BLOCK_SIZE)
Put #intFileId, , buf()
Next
If J <> 0 Then
ReDim buf(BLOCK_SIZE)
buf() = RsTmp("mFile").GetChunk(J)
Put #intFileId, , buf()
End If
Close #intFileId
Exit Sub
OpenErr:
MsgBox "Error! - " & Err.Description
Err.Clear
End Sub
mTempDoc 是指你要还原的文件的一个临时文件
例如:如果是jpg的图片,那么mtempdoc="c:\temp\temp.jpg"
如果是doc的文档,那么mtempdoc="c:\temp\temp.doc"
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货