Advertisement
Guest User

Untitled

a guest
May 11th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim filePath As String = lbl_file.Text
  2.         Dim slashPosition As Integer = filePath.LastIndexOf("\")
  3.         Dim filenameOnly As String = filePath.Substring(slashPosition + 1)
  4.  
  5.  
  6.         Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://url.com/public_html/windows/" & filenameOnly), System.Net.FtpWebRequest)
  7.         request.Credentials = New System.Net.NetworkCredential("file", "password")
  8.         request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
  9.         Dim path As String = lbl_file.Text
  10.  
  11.         Dim file() As Byte = System.IO.File.ReadAllBytes(path)
  12.  
  13.         Dim strz As System.IO.Stream = request.GetRequestStream()
  14.  
  15.  
  16.  
  17.         For offset As Integer = 0 To file.Length Step 1024
  18.             lbl_progress.Text = offset.ToString() + " bytes sent"
  19.             Dim chunkSize As Integer = file.Length - offset - 1
  20.             If chunkSize > 1024 Then chunkSize = 1024
  21.             strz.Write(file, offset, chunkSize)
  22.         Next
  23.         lbl_progress.Text = file.Length + " bytes sent"
  24.  
  25.         strz.Close()
  26.         strz.Dispose()
  27.  
  28.         MsgBox(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement