string url = "ftpUrl/FileName";
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(url);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("user name", "password");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
byte[] buffer = File.ReadAllBytes("path");
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(buffer, 0, buffer.Length);
}
using (Stream reqStream = request.GetRequestStream())
{
int count = 0;
byte[] buffer = new byte[100];
using (FileStream file = new FileStream("FileName", FileMode.Open))
{
while ((count = file.Read(buffer, 0, 100)) > 0)
{
reqStream.Write(buffer, 0, count);
}
}
}
Read more: שלמה גולדברג