I am uploading file through ftp using asp.net,c#. If my file size is small(3 MB) then it is uploading file bit if my file size is large then it is not uploading all file. it is uploading only about 3500 kb. i am using the following code.
try
{
string Path = Server.MapPath("~");
string filename = System.IO.Path.GetFileName(fImage1.PostedFile.FileName);
string ftpfullpath = ftpurl + filename;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
HttpPostedFile file = Request.Files[0]; //you can use inputid.PostedFile too
Stream str = file.InputStream;
byte[] buffer = new byte[file.ContentLength];
str.Read(buffer, 0, file.ContentLength);
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
lblMessage.Visible = false;
lblMessage.Text = "Your file has been uploaded successfully.";
}
catch (Exception ex)
{
lblMessage.Visible = false;
lblMessage.Text = ex.ToString();
}
How i will upload the large size file through ftp. Please suggest me.