This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: VB.NET  |  size: 1.11 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data