Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.Flush();
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(FullFilePath));
reqFTP.Proxy = null;
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential("userid", "password");
WebResponse aa = reqFTP.GetResponse();
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream ftpStream = response.GetResponseStream();
MemoryStream MemStream = new MemoryStream();
int bufferSize = 2048;
byte[] respBuffer = new byte[bufferSize];
try
{
int bytesRead = ftpStream.Read(respBuffer, 0, respBuffer.Length);
while (bytesRead > 0)
{
MemStream.Write(respBuffer, 0, bytesRead);
bytesRead = ftpStream.Read(respBuffer, 0, respBuffer.Length);
}
byte[] finalByte = MemStream.GetBuffer();
Response.BinaryWrite(finalByte);
Monday, February 15, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment