public string DownLoadImage(string fileName) { FtpWebRequest reqFTP; FileStream outputStream = new FileStream("Temp" + "\\" + fileName, FileMode.CreateNew); try { reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpURIIP + fileName)); reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); Stream ftpStream = response.GetResponseStream(); long cl = response.ContentLength; int bufferSize = 2048; int readCount; byte[] buffer = new byte[bufferSize]; readCount = ftpStream.Read(buffer, 0, bufferSize); while (readCount > 0) { outputStream.Write(buffer, 0, readCount); readCount = ftpStream.Read(buffer, 0, bufferSize); } ftpStream.Close(); outputStream.Close(); response.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return outputStream.Name; }
如何把这段代码改成返回 byte[] 格式的。