-
December 16th, 2013, 08:09 AM
#1
Able to Upload the file to FTP, but how to upload the 50MB file to FTP faster?
Hi All,
I am able to Upload the files to FTP server.
Now i would like to know how to upload the 50MB file faster, i mean it should take less time to upload to FTP.
In my code its taking 2min to upload the file.
So i require ur guidence....
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (TxtPath.Text.Length = 0 Or PvS_FileName.Length = 0) Then
MessageBox.Show("Please Select the File to Upload")
Return
End If
If Not IO.File.Exists(TxtPath.Text) Then
MessageBox.Show("Selected file doesn't exists")
Return
End If
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create(TxtUFTPPath.Text & PvS_FileName), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential("", "")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
''rfshTMR.Enabled = True
Dim File() As Byte = System.IO.File.ReadAllBytes(TxtPath.Text)
Dim clsStream As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(File, 0, File.Length)
For offset As Long = 0 To File.Length Step 2048
'For offset As Long = 0 To File.Length Step 1024
ProgressBar1.Value = CType(offset * ProgressBar1.Maximum / File.Length, Integer)
Dim chunkSize As Long = File.Length - offset - 1
'Dim chunkSize As Double = File.Length - offset - 1
If chunkSize > 1024 Then chunkSize = 1024
clsStream.Write(File, offset, chunkSize)
ProgressBar1.Value = ProgressBar1.Maximum
Next
clsStream.Close()
clsStream.Dispose()
MsgBox("File uploaded to FTP", MsgBoxStyle.OkOnly, "Upload Complete")
'for web brow
WebBrowser1.Refresh()
End Sub
Your help can make me learn
Thanks in Advance
Seema
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
|