Note: This post is first published on Nov-2011 in my previous blog Techkindle. Moving the content here.

Normal FTP file copying process using built in classes provided System.Net NameSpace.
The code is as follows, do not forget to add System.Net namespace.

using System;
using System.Net;
using System.IO;
namespace FtpFileCopy
public class FtpFileUpload
static void Main(string[] args)
public static bool ftpfileUpload(string inputfilepath)
string ftpMachinePath = "";
string ftpMachineUserName = "gopikreddy";
string ftpMachinePassword = "password";
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpMachinePath);
//userid and password for the ftp server to given
ftp.Credentials = new NetworkCredential(ftpMachineUserName, ftpMachinePassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(inputfilepath);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
return true;
catch (Exception ex)
return false;

view raw
hosted with ❤ by GitHub

Happy Learning 🙂