I am trying to upload a file to an FTP server using C#. My code works right for simple txt files, but when I want to upload a video the uploaded file is corrupted.
This is my code for reading the file:
StreamReader sourceStream = new StreamReader(File.InputStream);
var content = sourceStream.ReadToEnd();
EDIT: i changed my code like this :
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(HostName + '/' + Folder + '/' + FileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(UserName, Password);
byte[] fileContent = new byte[File.ContentLength];
Stream ftpstream = request.GetRequestStream();
ftpstream.Write(fileContent, 0, File.ContentLength);
ftpstream.Close();
ftpstream.Flush();
here i'm not using streamReader,but still there is the problem