title: Send a file over network - Bigger buffer-size than 2 impossible?
body: <p>I'm working on a client-server project, which contains a client-application and a server-application. The client-application can send a file to the server-application and the server-application receives this file and write it in his folder.
  The projectworks, but only with a (buffer)byte-array with a length of 2.</p>
  
  <p>The client-application and the server-application are both using a byte-array with a length of 2. If I choose a bigger size, such as 1024, than I have the problem, that the recieved file in the server-application has not the same size of the original file from the client-side. </p>
  
  <p>Client:</p>
  
  <pre><code>Byte[] fileBytes = new Byte[2];
  long count = filesize;
  while (count &gt; 0) 
  {
      int recieved = a.Read(fileBytes, 0, fileBytes.Length);
      a.Flush();
      nws.Write(fileBytes, 0, fileBytes.Length);
      nws.Flush();
      count -= recieved;
  }
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>long count = filesize;
  Byte[] fileBytes = new Byte[2];
  var a = File.OpenWrite(filename);
  while (count &gt; 0) 
  {
      int recieved = nws.Read(fileBytes, 0, fileBytes.Length);
      nws.Flush();
      a.Write(fileBytes, 0, fileBytes.Length);
      a.Flush();
      count -= recieved;
  }
  </code></pre>