FTP upload Control

Source: Internet
Author: User
Use ftpsupport for FTP upload

I recently used the FTP function to write down the upload code and make a mark.
Use support. dll. download it from here.
You need to reference this DLL before using it, and then using ftpsupport;

The following is the FTP upload code:/** // <summary>
/// FTP upload
/// </Summary>
/// <Param name = "localfile"> such as server. mappath ("~ /") +" Log.txt "</param>
/// <Param name = "Dr"> name of the FTP server directory, for example,/vagerent/image/</param>
/// <Param name = "newremotefile"> name of the file to be uploaded to the server, such as log.txt </param>
/// <Returns> </returns>
Private int ftpfile (string localfile, string DR, string newremotefile)
{
String remotedr = "/";
Ftpconnection FTP = new ftpconnection ();

Try
{
String ftpip = configurationsettings. receivettings ["ftpip"];
String ftpusrname = configurationsettings. receivettings ["ftpusrname"];
String ftpusrpsw = configurationsettings. receivettings ["ftpusrpsw"];
FTP. Connect (ftpip, ftpusrname, ftpusrpsw );
Remotedr = Dr;
FTP. setcurrentdirectory (remotedr );
FTP. putfile (localfile, newremotefile );
Return 1; // upload successful

}
Catch (exception ERR)
{
Return 0; // Upload Failed
}
Finally
{
FTP. Close ();
}
}

Reprinted here.

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.