Vb.net winform Ftp upload .... There are many methods, one I use .....

Source: Internet
Author: User
Code 1 Imports System
2 Imports System. IO
3 Imports System. Net
4 Imports System. Text
5 Public Class ftpUpload
6
7 Private Sub button#click (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles Button1.Click
8
9 Dim request As FtpWebRequest = DirectCast (WebRequest. Create ("http://www.cnblogs.com/Believeme/admin/ftp://76.73.62.252/123.xml"), FtpWebRequest)
10 request. Method = WebRequestMethods. Ftp. UploadFile
11
12
13 request. Credentials = New NetworkCredential ("3339", "libaoxin") 'user name and password
14
15 Dim sourceStream As New StreamReader ("D: \ 123.xml") 'file to be uploaded
16 Dim fileContents As Byte () = Encoding. UTF8.GetBytes (sourceStream. ReadToEnd ())
17 sourceStream. Close ()
18 request. ContentLength = fileContents. Length
19 Dim requestStream As Stream = request. GetRequestStream ()
20 requestStream. Write (fileContents, 0, fileContents. Length)
21 requestStream. Close ()
22 Dim response As FtpWebResponse = DirectCast (request. GetResponse (), FtpWebResponse)
23 response. Close ()
24 End Sub
25 End Class
26
27
Http://msdn.microsoft.com/zh-cn/library/ms229715 (VS.80). aspx
29

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.