Enviando arquivo binário TcpClient - arquivo é maior que a origem

Para colocar meu dedo na água da programação de rede, eu escrevi um pequeno aplicativo de console para enviar um arquivo png para um servidor (outro aplicativo de console). O arquivo que está sendo escrito pelo servidor é um pouco maior que o arquivo png de origem. E não vai abrir.

O código para o aplicativo cliente é:

    private static void SendFile()
    {
        using (TcpClient tcpClient = new TcpClient("localhost", 6576))
        {
            using (NetworkStream networkStream = tcpClient.GetStream())
            {
                //FileStream fileStream = File.Open(@"E:\carry on baggage.PNG", FileMode.Open);

                byte[] dataToSend = File.ReadAllBytes(@"E:\carry on baggage.PNG");

                networkStream.Write(dataToSend, 0, dataToSend.Length);
                networkStream.Flush();

            }
        }

    }

O código para o aplicativo do servidor é:

    private static void Main(string[] args)
    {
        Thread thread = new Thread(new ThreadStart(Listen));
        thread.Start();

        Console.WriteLine("Listening...");
        Console.ReadLine();
    }

    private static void Listen()
    {
        IPAddress localAddress = IPAddress.Parse("127.0.0.1");
        int port = 6576;
        TcpListener tcpListener = new TcpListener(localAddress, port);
        tcpListener.Start();

        using (TcpClient tcpClient = tcpListener.AcceptTcpClient())
        {
            using (NetworkStream networkStream = tcpClient.GetStream())
            {
                using (Stream stream = new FileStream(@"D:\carry on baggage.PNG", FileMode.Create, FileAccess.ReadWrite))
                {
                    // Buffer for reading data
                    Byte[] bytes = new Byte[1024];
                    var data = new List<byte>();

                    int length;

                    while ((length = networkStream.Read(bytes, 0, bytes.Length)) != 0)
                    {
                        var copy = new byte[length];
                        Array.Copy(bytes, 0, copy, 0, length);
                        data.AddRange(copy);
                    }

                    BinaryFormatter binaryFormatter = new BinaryFormatter();
                    stream.Position = 0;
                    binaryFormatter.Serialize(stream, data.ToArray());
                }
            }

        }
        tcpListener.Stop();

O tamanho do arquivo escrito é de 24.103Kb, enquanto o arquivo de origem é de apenas 24.079Kb.

É evidente para alguém por que esta operação está falhando?

Felicidades

questionAnswers(1)

yourAnswerToTheQuestion