Dim bytesread As Byte = 0
Dim buffer As Integer = 2
Dim Request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(Str_Url), System.Net.FtpWebRequest)
'Upload Properties
Request.Credentials = New System.Net.NetworkCredential(Str_Username, Str_Pwd)
Request.KeepAlive = False
Request.Proxy = Nothing
Request.UsePassive = True
Request.UseBinary = False
Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Request.Timeout = 180000
' Try
' read in file...
Dim fs As FileStream = File.OpenRead(Str_PathBase)
Dim bFile As Byte() = New Byte(8100) {}
Dim fstream As Stream = Request.GetRequestStream
' upload file...
IntRunTotal = fs.Length
Do
If Bgw_Process.CancellationPending = True Then
e.Cancel = True
Exit Do
Else
IntRunCount += 1
bytesread = fs.Read(bFile, 0, buffer)
fstream.Write(bFile, 0, bFile.Length)
Bgw_Process.ReportProgress(IntRunCount)
End If
System.Threading.Thread.Sleep(100)
Loop Until bytesread = 0
fstream.Close()
fstream.Dispose()
Dim intChunk, intOffset As Integer
Dim clsStream As System.IO.Stream = Request.GetRequestStream()
Dim bFile() As Byte = System.IO.File.ReadAllBytes(Str_PathBase)
IntRunTotal = bFile.Length
intChunk = bFile.Length / 100
'PgbProcess.Maximum = 100
For I As Integer = 1 To 100
If intOffset + intChunk > bFile.Length Then intChunk = bFile.Length - intOffset
clsStream.Write(bFile, intOffset, intChunk)
intOffset += intChunk
Bgw_Process.ReportProgress(I)
Next
clsStream.Close()
clsStream.Dispose()