Close() Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Dim r As New Random Dim sb As New StringBuilder For i As Integer = 1 To 8 Dim idx As Integer = r.Next(0, 35) sb.Append(s.Substring(idx, 1)) Next Using ms As New System.IO.MemoryStream sc.CaptureDeskTopRectangle(Me.boundsRect).Save(ms, System.Drawing.Imaging.ImageFormat.Png) Using wc As New System.Net.WebClient wc.UploadData("ftp://MYUSERNAME:MYPASSWORD@MYSITE.COM/" + sb.ToString() + ".png", ms.ToArray()) End Using End Using Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Static r As New Random Dim sb As New StringBuilder For i As Integer = 1 To 8 Dim idx As Integer = r.Next(0, 35) sb.Append(s.Substring(idx, 1)) Next Using ms As New System.IO.MemoryStream sc.CaptureDeskTopRectangle(Me.boundsRect).Save(ms, System.Drawing.Imaging.ImageFormat.Png) Using wc As New System.Net.WebClient AddHandler wc.UploadDataCompleted, AddressOf UploadCompleted wc.UploadData("ftp://MYUSERNAME:MYPASSWORD@MYSITE.COM/" + sb.ToString() + ".png", ms.ToArray()) End Using End Using Private Sub UploadCompleted(sender As Object, e As Net.UploadDataCompletedEventArgs) 'do completed work here End Sub Public Shared Sub Main() ' Get the object used to communicate with the server. Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://www.contoso.com/test.htm"), FtpWebRequest) request.Method = WebRequestMethods.Ftp.UploadFile ' This example assumes the FTP site uses anonymous logon. request.Credentials = New NetworkCredential("anonymous", "janeDoe@contoso.com") ' Copy the contents of the file to the request stream. Dim sourceStream As New StreamReader("testfile.txt") Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd()) sourceStream.Close() request.ContentLength = fileContents.Length Dim requestStream As Stream = request.GetRequestStream() requestStream.Write(fileContents, 0, fileContents.Length) requestStream.Close() Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse) Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription) response.Close() End Sub