Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
QuestionIs there a way to write an bit to a binary file (NOT a byte) in C# ? [modified] Pin
Alex Manolescu28-Dec-09 13:26
Alex Manolescu28-Dec-09 13:26 
AnswerRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
harold aptroot28-Dec-09 13:33
harold aptroot28-Dec-09 13:33 
NewsRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
Alex Manolescu28-Dec-09 13:58
Alex Manolescu28-Dec-09 13:58 
GeneralRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
harold aptroot28-Dec-09 14:17
harold aptroot28-Dec-09 14:17 
GeneralRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
Alex Manolescu28-Dec-09 14:24
Alex Manolescu28-Dec-09 14:24 
GeneralRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
harold aptroot28-Dec-09 14:58
harold aptroot28-Dec-09 14:58 
GeneralRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
Alex Manolescu28-Dec-09 21:25
Alex Manolescu28-Dec-09 21:25 
AnswerRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? PinPopular
Luc Pattyn28-Dec-09 13:57
sitebuilderLuc Pattyn28-Dec-09 13:57 
Hi,

in a file system such as FAT or NTFS, files get allocated in multiples of sectors (512B) or clusters (several sectors). So you can't create a non-empty file of less than 512B of disk space.

the logical file length is expressed in bytes, so you can't create a non-empty file of less than 8 bits.

BitArray.Get() returns a bool; BinaryWriter.Write(bool) writes a byte, the doc says "Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing true." That could be lazyness, or a defense against unaligned data. If it were to write a single bit, a consequent Write(int) would be misaligned, and the total logical length would not necessarily be a multiple of 8.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Merry Christmas and a Happy New Year to all.


NewsRe: Is there a way to write an bit to a binary file (NOT a byte) in C# ? Pin
Alex Manolescu28-Dec-09 14:00
Alex Manolescu28-Dec-09 14:00 
QuestionClass with parameter of type Pin
Jeroen De Dauw28-Dec-09 12:30
Jeroen De Dauw28-Dec-09 12:30 
AnswerRe: Class with parameter of type Pin
Luc Pattyn28-Dec-09 12:35
sitebuilderLuc Pattyn28-Dec-09 12:35 
GeneralRe: Class with parameter of type Pin
Jeroen De Dauw28-Dec-09 13:16
Jeroen De Dauw28-Dec-09 13:16 
GeneralRe: Class with parameter of type Pin
Luc Pattyn28-Dec-09 13:18
sitebuilderLuc Pattyn28-Dec-09 13:18 
GeneralRe: Class with parameter of type Pin
Jeroen De Dauw28-Dec-09 13:39
Jeroen De Dauw28-Dec-09 13:39 
GeneralRe: Class with parameter of type Pin
Luc Pattyn28-Dec-09 13:46
sitebuilderLuc Pattyn28-Dec-09 13:46 
GeneralRe: Class with parameter of type Pin
Jeroen De Dauw28-Dec-09 23:44
Jeroen De Dauw28-Dec-09 23:44 
QuestionReading in Unicode text Pin
elmernite28-Dec-09 10:48
elmernite28-Dec-09 10:48 
AnswerRe: Reading in Unicode text Pin
Luc Pattyn28-Dec-09 11:15
sitebuilderLuc Pattyn28-Dec-09 11:15 
QuestionRe: Reading in Unicode text [modified] Pin
elmernite29-Dec-09 3:58
elmernite29-Dec-09 3:58 
AnswerRe: Reading in Unicode text Pin
Luc Pattyn29-Dec-09 5:20
sitebuilderLuc Pattyn29-Dec-09 5:20 
GeneralRe: Reading in Unicode text Pin
elmernite29-Dec-09 5:56
elmernite29-Dec-09 5:56 
QuestionC# and Open Gl Pin
awaistariq28-Dec-09 7:44
awaistariq28-Dec-09 7:44 
AnswerMessage Closed Pin
28-Dec-09 7:51
stancrm28-Dec-09 7:51 
GeneralRe: C# and Open Gl Pin
harold aptroot28-Dec-09 8:54
harold aptroot28-Dec-09 8:54 
AnswerRe: C# and Open Gl Pin
#realJSOP28-Dec-09 9:41
mve#realJSOP28-Dec-09 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.