Reading BITS?
Reading BITS?
Reading BITS?
Reading BITS?
Reading BITS?
Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS?
Reading BITS? Reading BITS?
Reading BITS?
Go Back  Xtreme Visual Basic Talk > > > Reading BITS?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2010, 07:21 PM
axle12693 axle12693 is offline
Freshman
 
Join Date: May 2009
Posts: 26
Default Reading BITS?


OK, everyone knows how to read bytes from a file... but is it possible to read each individual bit, one at a time?
Reply With Quote
  #2  
Old 08-29-2010, 09:02 AM
OnErr0r's Avatar
OnErr0rReading BITS? OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

The smallest unit which can be read from a drive is a byte. Start by creating a new FileStream and pass the stream to a new BinaryReader. Use the BinaryReader.Byte() method to get a particular byte. Then mask off the bit in question and shift it right the appropriate number of bits to get a 1 or 0.

For information on shifting and masking read my Bits, Bytes and Bases tutorial in the Legacy Tutors' Corner. Note that starting with VS 2003 (Framework 1.1) vb.net gained shifting operators, which make division/multiplication by powers of two unnecessary.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reading BITS?
Reading BITS?
Reading BITS? Reading BITS?
Reading BITS?
Reading BITS?
Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS? Reading BITS?
Reading BITS?
Reading BITS?
 
Reading BITS?
Reading BITS?
 
-->