socket传送文件问题
如何将服务器端的文件(如.txt)根据指定条件发送到指定的客户端去(有提供ip地址)?希望有高手给出代码!(c#) --------------------编程问答-------------------- private void btSend_Click(object sender, System.EventArgs e)
{
if (this._isConnect)
{
_ns = _tc.GetStream();
string path = this.txtPath.Text.Trim();
FileStream fs = new FileStream(path, FileMode.Open);
int sendCount = 0;
byte[] countbuffer = null;
byte[] clientbuffer = new byte[1004];
while (sendCount < fs.Length && _ns.CanWrite)
{
int count = fs.Read(_sendBuf, 0, _sendBuf.Length); //读出要发送的数据
countbuffer = BitConverter.GetBytes(count);
countbuffer.CopyTo(clientbuffer,0);
_sendBuf.CopyTo(clientbuffer, 4);
this._ns.Write(clientbuffer, 0, 4 + count); //写入网络流
sendCount += count;
}
countbuffer = BitConverter.GetBytes(0); //发送完文件后 发送count = 0
this._ns.Write(countbuffer, 0, countbuffer.Length); //使接收端停止
_ns.Close();
fs.Close();
}
} --------------------编程问答--------------------
我是菜鸟。不能明白你的代码,能不能说明白点。怎么发送到客户端上? --------------------编程问答--------------------
我是菜鸟。不能明白你的代码,能不能说明白点。怎么发送到客户端上? --------------------编程问答-------------------- http://jimmyzhang.cnblogs.com/
补充:.NET技术 , C#