title: writing bytes to a file vb.net
body: <p>Why doesn't this code works ? :( , want to read from a binary file, then load the bytes to bitarray, then perform changes to bit array, then copy changes to the byte array then write changes to the file using the byte array. I'll provide commentary in the code.</p>
  
  <pre><code>Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  
      'Want to read from the binary file
      Dim array() As Byte = File.ReadAllBytes("E:\binfile.bin")
  
      'to create the bit array   
      Dim ba1 As BitArray = New BitArray(8)
  
      ba1 = New BitArray(array)
  
      'want to set 1st bit to false (ie:0)
      ba1.Set(0, False)
  
      'want to set the changes made to bit array to binary array
      array.SetValue(ba1(0), 0)
  
      'want to save the binary file using binarywriter
      File.WriteAllBytes("E:\binfile.bin", array)
  End Sub
  </code></pre>