I want to upload a file to my FTP Server and the values for the credentials are userlabel passlabel and servlabel these are all the corresponding labels for the credentials.. Passlabel and userlabel are actually mixed up.. pass is user and userlabel is the password. I want to implement a prgressbar and I don’t know how to do it someone please help
Here is my code so far.
Private Sub BW_DoWork(ByVal sender As System.Object,
ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BW.DoWork
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create(ServLabel.Text &
TextBox1.Text),
System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(PassLabel.Text, UserLabel.Text)
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(txtFile.Text)
' upload file...
Dim clsStream As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
BW.ReportProgress(clsStream.Position.ToString)
MsgBox("File Is Now In Database", MsgBoxStyle.OkOnly, "Upload Complete")
End Sub
You could pass only a part of the array
bFileto theclsStream.Write()method and repeat it until all parts has been written to the stream.