打印本文 打印本文 关闭窗口 关闭窗口
VB断点拷贝大文件
作者:武汉SEO闵涛  文章来源:敏韬网  点击数7618  更新时间:2009/4/23 15:43:36  文章录入:mintao  责任编辑:mintao
lngTotal = FileLen(textFrom.Text) lblTotal.Caption = "共计 " & VBStrFormatByteSize(lngTotal) lngFrom = OpenFile(textFrom.Text, myResult, OF_READ) ''''If myResult.nErrCode > 0 Then '''' Err.Raise 0, , "打开源文件错误,文件:" & textFrom.Text & " 错误号:" & myResult.nErrCode ''''End If If Dir(textTo.Text) = "" Then lngTo = OpenFile(textTo.Text, myResult, OF_CREATE) lngCurrent = 0 Else lngCurrent = FileLen(textTo.Text) lStart = CLng(TextStart.Text) * 1024 lngTo = OpenFile(textTo.Text, myResult, OF_WRITE) If lStart > 0 And lngCurrent > lStart Then SetFilePointer lngTo, lStart, 0, FILE_BEGIN lngCurrent = lStart Else Call SetFilePointer(lngTo, 0, 0, FILE_END) End If End If ''''If myResult.nErrCode > 0 Then '''' Err.Raise 0, , "打开目标文件错误,文件:" & textFrom.Text & " 错误号:" & myResult.nErrCode ''''End If If lngCurrent >= lngTotal Then bolStop = True Else If lngCurrent > 0 Then SetFilePointer lngFrom, lngCurrent, 0, FILE_BEGIN End If bolStop = False End If myCount.Clear bolUnload = False lBlankCount = 0 lblBlank.Caption = "" Do If bolStop = True Then GoTo CopyExit ''''picStatus.BackColor = Me.BackColor ReadFile lngFrom, VarPtr(buf(0)), c_BufSize, lngCopy, 0 If lngCopy <> c_BufSize And lngCurrent <> lngTotal And lngCurrent + lngCopy <> lngTotal Then If chkFillData.Value = 1 Then For lCount = 0 To c_BufSize - 1 buf(lBlankCount) = &HFF Next lCount lBlankCount = lBlankCount + 1 lngCopy = lngTotal - lngCurrent lblBlank.Caption = "填充空白数据:" & VBStrFormatByteSize(lBlankCount * c_BufSize) If lngCopy > c_BufSize Then lngCopy = c_BufSize End If picStatus.BackColor = vbRed SetFilePointer lngFrom, lngCurrent + lngCopy, 0, FILE_BEGIN Else Exit Do End If Else picStatus.BackColor = vbGreen End If WriteFile lngTo, VarPtr(buf(0)), lngCopy, lngCopy, 0 lngCurrent = lngCurrent + lngCopy myCount.Count lngCopy ''''** 设置进度信息 strRate = Format(lngCurrent / lngTotal, "0.00%") lblInfo.Caption = "目前完成 " _ & VBStrFormatByteSize(lngCurrent) & "(" & strRate & ")" If myCount.NewSpeed Then lblSpeed.Caption = "速度:" & VBStrFormatByteSize(myCount.Speed) & "/秒" End If Me.Caption = strRate If lngCurrent * 100# / lngTotal > 100 Then myProc.Value = 100 Else myProc.Value = lngCurrent * 100# / lngTotal End If DoEvents Loop Until lngCopy <> c_BufSize CopyExit: CloseHandle lngFrom CloseHandle lngTo lblInfo.Caption = "共拷贝 " & VBStrFormatByteSize(lngCurrent) & ",所花时间 " & myCount.TotalTickCount & " 毫秒" lblSpeed.Caption = "平均速度: &qu

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  下一页

打印本文 打印本文 关闭窗口 关闭窗口