How do I perform FTP on a text file which contains both English and French characters?
The normal FTP convert the French character to junk data. Thats created a lot of confusion at the mainframe side.
byte[] fileContent = File.ReadAllBytes(ftpFileLocation);
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContent, 0, fileContent.Length);
requestStream.Close();
This is an encoding issue.
I fixed this by using the below code. You can see, instead of ReadAllByes, I read all the text in string format and converted to specific encoding.
The same logic will be useful in other languages as well.
byte[] fileContent = Encoding.GetEncoding("iso-8859-1").GetBytes(File.ReadAllText(ftpFileLocation));
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContent, 0, fileContent.Length);
requestStream.Close();