Results 1 to 4 of 4

Thread: Filemanager problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    1

    Filemanager problem

    Hello! Im coding a filemanager and I need some help.
    The download speed is very slow.

    The arrived packets are loaded into memory (4 kb/packet) and that also makes the program very slow. The packets should get into the file as soon as they arrived.
    Can you help me to fix the code? Code (Client side):

    VB Code:
    1. 'Module
    2. Public CurrentDirectory As String
    3. Public intFile As Integer
    4. Public lngFileSize As Long
    5. Public lngFileProg As Long
    6. Public StrFileName As String
    7. Public RequestedFile As String
    8. Public tmpstring As String
    9. Public screenshot As Boolean
    10. -------------------------------------------------------------------
    11.  
    12.  
    13. Private Sub ClientSck_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    14. Dim arrLines() As String
    15. Dim i As Integer
    16. Dim Lines As Long
    17. Dim All_data As String
    18. Dim Clean_Data As String
    19. Dim Temp_Data As String
    20. Dim NData() As String
    21. Dim FileBuffer As String
    22.  
    23. ClientSck(Index).GetData All_data, vbString
    24. NData = Split(All_data, "|")
    25. Select Case NData(0)
    26.  
    27.  
    28.  
    29.  
    30.         Case "SEND_FILE": lngFileSize = Int(NData(1)): Filemanager.ProgressBar.Max = lngFileSize: Filemanager.lblPercent.Caption = "0%": intFile = FreeFile
    31.                           lngFileSize = Int(NData(1)): Screencapture.PB.Max = lngFileSize
    32.                           SckNumber = lstConTable.ListItems.Item(lstConTable.SelectedItem.Index)
    33.                           If FileExists(StrFileName) Then
    34.                               Kill StrFileName: DoEvents
    35.                           End If
    36.                           Open StrFileName For Binary Access Write As intFile: ClientSck(SckNumber).SendData "ACPT_FILE" & "|" & RequestedFile: lngFileProg = 0
    37.  
    38.  
    39.  
    40.         Case "CHNK_DATA"
    41.             SckNumber = lstConTable.ListItems.Item(lstConTable.SelectedItem.Index)
    42.             All_data = Mid$(All_data, 11, Len(All_data) - 10)
    43.  
    44.             If (lngFileProg + 4096) < lngFileSize Then
    45.                 lngFileProg = lngFileProg + 4096
    46.                 Filemanager.ProgressBar.Value = Filemanager.ProgressBar.Value + 4096
    47.                 Filemanager.lblPercent.Caption = Format$((Filemanager.ProgressBar.Value / Filemanager.ProgressBar.Max * 100), "##.##") & "%"
    48.                 Screencapture.PB.Value = Screencapture.PB.Value + 4096
    49.                 Put intFile, , All_data
    50.                 ClientSck(SckNumber).SendData "CHNK_FILE"
    51.  
    52.             Else
    53.  
    54.                 All_data = Left$(All_data, lngFileSize - lngFileProg)
    55.                 Filemanager.ProgressBar.Value = Filemanager.ProgressBar.Max
    56.                 Filemanager.lblPercent.Caption = "100%"
    57.                 Put intFile, , All_data
    58.                 ClientSck(SckNumber).SendData "DONE_FILE"
    59.                 Close intFile
    60.                 Filemanager.ProgressBar.Value = 0
    61.                  Screencapture.PB.Value = 0
    62.                 Filemanager.lblPercent.Caption = vbNullString
    63.  
    64.                 If screenshot = True And StrFileName = App.Path & "\CompressedSS.cmp" Then
    65.                     screenshot = False
    66.                     DecompressFile App.Path & "\CompressedSS.cmp", App.Path & "\Screencapture.bmp"
    67.                     Kill App.Path & "\CompressedSS.cmp"
    68.                     Screencapture.Picture1.Picture = LoadPicture(App.Path & "\Screencapture.bmp")
    69.   Screencapture.Picture1.ScaleMode = 3
    70.     Screencapture.Picture1.AutoRedraw = True
    71.     Screencapture.Picture1.PaintPicture Screencapture.Picture1.Picture, _
    72.         0, 0, Screencapture.Picture1.ScaleWidth, Screencapture.Picture1.ScaleHeight, _
    73.         0, 0, _
    74.         Screencapture.Picture1.Picture.Width / 26.46, _
    75.         Screencapture.Picture1.Picture.Height / 26.46
    76.     Screencapture.Picture1 = Screencapture.Picture1.Image
    77.  
    78.                 Else
    79.  
    80.                     statBar.SimpleText = "Status: Command Executed"
    81.                     MsgBox "Download Finished" & vbNewLine & vbNewLine & "Total Recived: " & Format$(Filemanager.ProgressBar.Max, "###,###,###,###") & " bytes", vbOKOnly, "Nedladdnings status"
    82.  
    83.                 End If
    84.             End If
    Last edited by marjinz; Oct 27th, 2006 at 12:02 PM.

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Filemanager problem

    Have a look at a file manager I made along time ago, might be a couple bugs in the directory listing, but everything else works. It comes with a file transfer control (sender/receiver) to make transferring files pretty easy.

    I plan on updating the code soon since back then I wasn't real experienced with winsock, or VB in general.

    http://www.pscode.com/vb/scripts/Sho...50253&lngWId=1

    If you have any questions let me know.

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Filemanager problem

    Also, a 4KB packet size is kind of big. Remember that, no matter how big you set your packet size, only so much data can get through at one time. This is limited by Windows (TCP/IP) settings and network interface drivers. A large packet size will not make the transfer go any faster. I would set it at about 512 bytes or 1KB at most. Packet size will not really determine the rate of download (KBPS) unless you set it extremely low, and even then it will have minimal effect.

    It also looks like you're sending/receiving files using strings to hold the data.

    Use a byte array. If the file you're sending is a binary file, you will want to use a byte array to store/write the data to disk.

    You could change your parsing routine to work with a byte array, or alternatively, use 2 ports. One for sending the file info, the other for transferring the file data.

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Filemanager problem

    Im doing similar program to copy files thru tcp/ip, but the size of files will be 5 to 7 MB and there are lots of files to be transferred at one time...any help on transferring large size files thru tcp/ip
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width