This should be pretty straight forward, and uploading works. BUT when I open the uploaded file on the FTP server it shows binary data which is just some weird characters that look like this [][][][], and its the right file size. how do I add attributes or headers that that will say that this file is an XML?
public bool ProcessBatch(MemoryStream memStream)
{
bool result = true;
FTPaddress = DistributionResources.ftpServer;
CompleteFTPPath = DistributionResources.ftpPath;
request = (FtpWebRequest)FtpWebRequest.Create(FTPaddress + CompleteFTPPath);
request.Credentials = new NetworkCredential("username", "password");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
try
{
byte[] buffer = new byte[memStream.Length];
memStream.Read(buffer, 0, buffer.Length);
memStream.Close();
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(buffer, 0, buffer.Length);
}
//Gets the FtpWebResponse of the uploading operation
response = (FtpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusDescription); //Display response
}
catch(Exception ex)
{
result = false;
}
return result;
}
Thank you very much