خوب اقا از اینکه پیگیری باز هم ممنونم
این کد رو ببین
private void save_Btn_Click(object sender, EventArgs e)
{
BitArray bits = new BitArray(8);
FileStream fileReader = new FileStream(openFileDialogFileHolder.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
Int32 size = Convert.ToInt32(fileReader.Length);
byte[] byteFile = new byte[size];
fileReader.Read(byteFile, 0, size);
foreach (Byte B in byteFile2)
{
BitArray myBA2 = new BitArray(BitConverter.GetBytes(B).ToArray());
myBA[1] = myBA2[5];
myBA2[3] =true;myBA2[2] =false;myBA2[1] =false;
byteFile[index] = (BitArrayToByteArray(myBA));
{
FileStream write = new FileStream(saveFileDialogCombinedFile.FileName, FileMode.Create, FileAccess.Write);
BinaryWriter bin = new BinaryWriter(write);
bin.Write(byteFile);
}
public byte[] BitArrayToByteArray(BitArray ba)
{
byte[] bytes;
if (ba.Length % 8 == 0)
{
bytes = new byte[ba.Length / 8];
}
else
{
bytes = new byte[ba.Length / 8 + 1];
}
for (int i = 0; i < ba.Length; i += 8)
{
int pos = i / 8;
for (int j = 0; j < 8; j++)
{
if (i + j < ba.Length)
{
if (ba[i + j] == true)
{
bytes[pos] &= 1;
}
}
bytes[pos] <<= 1;
}
}
return bytes;
}