111,094
社区成员




public void ReceiveMsg( TcpClient tmpTcpClient )
{
try
{
if ( tmpTcpClient.Connected )
{
NetworkStream ns = tmpTcpClient.GetStream( );
byte[] receiveBytes = new byte[tmpTcpClient.ReceiveBufferSize];
FileStream fs = new FileStream( "D:\\aa.png" , FileMode.Create );
bool isfirst = true;
int i = 0;
while ( ns.Read( receiveBytes , 0 , receiveBytes.Length ) > 0 )
{
if ( isfirst )
{
fs.Write( receiveBytes , 4 , receiveBytes.Length - 4 );
isfirst = false;
}
else
{
fs.Write( receiveBytes , 0 , receiveBytes.Length );
}
}
if ( fs != null )
{
fs.Dispose( );
}
}
}
catch ( Exception ex )
{
MessageBox.Show( "出问题了" );
}
}