This should be fairly straight forward and load work. BUT, when I open the downloaded file on an FTP server, it shows binary data, which are just some weird characters that look like [] [] [] [], and its correct file size. how to add attributes or headers that say this file is 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);
}
response = (FtpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusDescription);
}
catch(Exception ex)
{
result = false;
}
return result;
}
Many thanks
source
share