V
VanBurg
Hallo!
I have to do the following tasks:
1) I need to read first 4 bytes from file
2) Get all 32 bits for editing
3) Change some bits and save its back to file
For now i have to understand how to do only this:
FileStream fs = File.OpenRead (fileName);
fs.Read (this.HeaderBytes, 0, 4);
this.HeaderBits = new BitArray (this.HeaderBytes);
But bitarray will have (absolutely right) indexes, but i cannot do the following:
this.HeaderBits[8] = true;
'couse it will not change a byte at position 8 from left
XXXX XXXX [X]XXX XXXX
it will change
XXXX XXXX XXXX XXX[X]
Please give me easy and elegant way to manage bits< for example it may work like this:
Header.SetBit (byte pos, bool value);
Header.Save ();
Many thanks!
I have to do the following tasks:
1) I need to read first 4 bytes from file
2) Get all 32 bits for editing
3) Change some bits and save its back to file
For now i have to understand how to do only this:
FileStream fs = File.OpenRead (fileName);
fs.Read (this.HeaderBytes, 0, 4);
this.HeaderBits = new BitArray (this.HeaderBytes);
But bitarray will have (absolutely right) indexes, but i cannot do the following:
this.HeaderBits[8] = true;
'couse it will not change a byte at position 8 from left
XXXX XXXX [X]XXX XXXX
it will change
XXXX XXXX XXXX XXX[X]
Please give me easy and elegant way to manage bits< for example it may work like this:
Header.SetBit (byte pos, bool value);
Header.Save ();
Many thanks!