C # upload files through FTP .,

Source: Internet
Author: User

C # upload files through FTP .,

Something is not very complicated, but Baidu seems to be a kind of code. The code is too long to be copied. Let's paste the Code directly in a simple version.

1 // <summary> 2 // upload ftp service 3 /// </summary> 4 // <param name = "path"> file address </param> 5 /// <returns> </returns> 6 public string Upload (string path) 7 {8 var client = new WebClient (); 9 client. credentials = new NetworkCredential ("fptuser", "ftppwd"); // user name and password 10 client. baseAddress = "ftpurl"; // ftp address 11 string ftpPath = client. baseAddress + "/TestFileUpLoad/" + Guid. newGuid (); // upload fptp path 12 string returnPath = ""; 13 try14 {15 client. uploadFile (ftpPath, path); 16 returnPath = ftpPath; 17} 18 catch (Exception ex) 19 {20 // handle error information 21} 22 return returnPath; 23}

 

Related Article

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.