日期:2014-05-19  浏览次数:20813 次

C#实现ftp文件传输源码(winform),分不够再加
我想要一个完整的   能调试一步一步看步骤实现功能的例子
不用很复杂的功能
tcp和ftp   最好都有一份

------解决方案--------------------
using System;
using System.IO;
using System.Net.Sockets;

namespace ftpClientUtil
{
internal class FtpWebStream : Stream
{
private FtpWebResponse response;
private NetworkStream dataStream;

public FtpWebStream(NetworkStream dataStream, FtpWebResponse response)
{
this.dataStream = dataStream;
this.response = response;
}

public override void Close()
{
response.Close();
base.Close();
}

public override void Flush()
{
dataStream.Flush();
}

public override int Read(byte[] buffer, int offset, int count)
{
return dataStream.Read(buffer, offset, count);
}

public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException( "Seek not supported. ");
}

public override void SetLength(long value)
{
throw new NotSupportedException( "SetLength not supported. ");
}

public override void Write(byte[] buffer, int offset, int count)
{
dataStream.Write(buffer, offset, count);
}

public override bool CanRead
{
get { return dataStream.CanRead; }
}

public override bool CanSeek
{
get { return false; }
}

public override bool CanWrite
{
get { return dataStream.CanWrite; }
}

public override long Length
{
get { throw new NotSupportedException( "Length not supported. "); }
}

public override long Position
{
get
{
throw new NotSupportedException( "Position not supported. ");
}
set
{
throw new NotSupportedException( "Position not supported. ");
}
}
}
}

------解决方案--------------------
using System;
using System.Net.Sockets;


/// <summary>
/// Ftp 的摘要说明。
/// </summary>
public class Ftp
{
public Ftp()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
string _ser;
public string Server
{
set{ _ser=value;}
get{return _ser;}
}
string _port;
public string Port
{
set{_port=value;}
get{return _port;}
}
string _user;
public string User
{
set{ _user=value;}
get{return _user;}
}
string _pws;
public string Password
{
set{ _pws=value;}
get{return _pws;}
}
bool _IsLog;
public bool IsLogined
{
set{ _IsLog=value;}
get{return _IsLog;}
}
int _MsgID;
public int MsgID
{
set{ _MsgID=value;}
get{return _MsgID;}
}
System.Windows.Forms.Label _infx=new System.Windows.Forms.Label() ;
public System.Window