title: FileStream Read slow in VB
body: <p>I try to read a File from a network device, and I would ony like to measure the time, it needs to read the file ( so to check the performance of the device + network ).</p>
  
  <p>If I use robocopy, I can see a speed of 120Mbit/s ( via wireshark I can see a Packet size of 32kByte ).</p>
  
  <p>If I use this code:</p>
  
  <pre><code>Private Sub LangerVorgang()
      Dim sb As New IO.FileStream(TextBox1.Text, IO.FileMode.OpenOrCreate)
      sr = sb
      len = sr.Length - 1
      Dim buffer(32768) As Byte
      Dim bytesread As Integer
      pos = sr.Position
  
      While sr.Position &lt; len
          bytesread = (sr.Read(buffer, 0, 32768))
      End While
      sr.Close()
  End Sub
  </code></pre>
  
  <p>I only get about 90Mbit/s, via Wireshark it uses also 32kByte.</p>
  
  <p>This code, runs in a seperate Thread.</p>
  
  <p>Can somebody tell me, why this is slow?</p>
  
  <p>If I make a bigger buffer ( like 1M ) it is faster, but then the measurement is much worse, so I would like to use about 32kByte.</p>
  
  <p>Thank you</p>