|
-
Nov 26th, 2000, 11:06 AM
#1
Thread Starter
New Member
Dear All:
This code is downloaded from other site. and i have the problem, After i transfer a file, the received file always bigger then original one. there are a lot of blank space at the end of the received file. how should i do to solve this problem?
Thank you very much
ps. You can download the full source code at the following address:
http://www.planet-source-code.com/up...8804892000.zip
ps1. here are the transfer and receive sections of the code!!
Transfer:
----------------------------------------------------------
Dim OpenedFileNbr, FileLength, Back
Dim Temp As String
Dim PackageSize As Long
Dim LastData As Boolean
FileLength = FileLen(Txt_File.Text)
FileBar.Max = FileLength
FileBar.Value = 0
Winsock_Send.SendData ("FILEINFO|" & FileLength & "|" & Lbl_FileName.Caption & "|")
StartTime = Timer
Do While NextPart = False And Timer - StartTime < 30
DoEvents
Loop
If Timer - StartTime > 30 Then GoTo Timeout
PackageSize = 2048
LastData = False
NextPart = True
OpenedFileNbr = FreeFile
Open Txt_File.Text For Binary Access Read As OpenedFileNbr
Temp = ""
Do Until EOF(OpenedFileNbr)
If FileLength - LOF(OpenedFileNbr) <= PackageSize Then
PackageSize = FileLength - Loc(OpenedFileNbr) + 1
LastData = True
End If
Temp = Space$(PackageSize)
Get OpenedFileNbr, , Temp
If Winsock_Send.State <> 7 Then Exit Sub '
On Error Resume Next
StartTime = Timer
Do While NextPart = False And Timer - StartTime < 30
DoEvents
Loop
If Timer - StartTime > 30 Then GoTo Timeout
If Winsock_Send.State = 7 Then
If LastData = True Then
Temp = Mid(Temp, 1, Len(Temp) - 1)
End If
FileBar.Value = FileBar.Value + Len(Temp)
Lbl_Complete.Caption = "Complete: " & Int(100 / FileLength * FileBar.Value) & " %"
DoneBytes = DoneBytes + Len(Temp)
Winsock_Send.SendData Temp
NextPart = False
Else
Exit Sub
End If
Loop
Close #OpenedFileNbr
Do While NextPart = False DoEvents
Loop
Winsock_Send.Close
Receive:
----------------------------------------------
Dim StrData As String
Dim lNewValue As Long
Dim Info As String
Dim Glob_FileName As String
StrData = ""
Winsock_Receive.GetData StrData, vbString
Info = Left(StrData, 8)
If Info = "FILEINFO" Then
FileBar.Max = GetField(StrData, 2)
Glob_FileName = GetField(StrData, 3)
Txt_File.Text = Glob_FileName
DownloadingFile = FreeFile
Open App.Path & "\" & Glob_FileName For Binary Access Write As #DownloadingFile
Exit Sub
End If
FileBar.Value = FileBar.Value + bytesTotal
DoneBytes = DoneBytes + bytesTotal
Lbl_Complete.Caption = "Complete: " & Int(100 / FileBar.Max * FileBar.Value) & " %"
Put #DownloadingFile, , StrData
DoEvents
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|