C# 实现FTP上传与下载

向FTP服务器下载文件的简单实例

Code
                
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 err) 
            { 
                MessageBox.Show(err.Message,
"Download Error");
            }

 

向FTP服务器上传文件的简单实例

Code
posted @ 2009-04-28 09:21  ∮随风而行∮  阅读(425)  评论(0编辑  收藏  举报