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.