首页 新闻 搜索 专区 学院

ftp下载图片

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-09-18 14:56
   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[]  格式的。

豌豆夹的主页 豌豆夹 | 初学一级 | 园豆:6
提问于:2015-09-16 16:15
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册