Here is my code.
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("path");
ftpRequest.Credentials = new NetworkCredential("log", "pass");
ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
byte[] fileContent; //in this array you'll store the file's content
using (StreamReader sr = new StreamReader(@"pathToFile")) //'myFile.txt' is the file we want to upload
{
fileContent = Encoding.UTF8.GetBytes(sr.ReadToEnd()); //getting the file's content, already transformed into a byte array
}
using (Stream sw = ftpRequest.GetRequestStream())
{
sw.Write(fileContent, 0, fileContent.Length); //sending the content to the FTP Server
}
.txt files upload correctly with content but .pdf file not. Have no idea where problem is.