title: Writing Bits into Binary File in VB.Net
body: <p>I need to create a file that include binary input but when i do this it take as byte not bit</p>
  
  <p>for example if i want to add binary represent of "apple" 
  it writes to file 0110000101110000011100000110110001100101 it contains 40 bits 
  however when i look at the file it show 40bytes because it takes every bit as char and so it save as byte-wise.
  How can i prevent this and save all information bit-wise in VB.net ?</p>
  
  <pre><code>Dim fs As New FileStream("\binfile.bin", FileMode.Append)
      Dim bw As New BinaryWriter(fs)
      Dim TempStr As String
  
      For t As Integer = 0 To Nameoftable.Length - 1
          Dim bin As String = _
              LongToBinary(Asc(Nameoftable.Substring(t, 1))) 'BIT CONVERTER FUNCTION
          TempStr &amp;= bin.Substring(bin.Length - 8)
      Next t
  
          bw.Write(TempStr)
  
      bw.Close()
  </code></pre>
  
  <p>Thanks a lot...</p>