I have a text file that contains a set of records and i am trying to convert and save it as 1's and 0's .. every time I use
Byte [] arr=Encoding.UTF8.GetBytes(recordss) ;
and write it using a byte writer i still have to same record file with no difference.
So my question is there a way to convert a string to binary and write it to a file in binary format. I am using c# by the way
Here is my code so far
public static void serialData()
{
FileStream recFile = new FileStream("Records.txt", FileMode.Open, FileAccess.ReadWrite); //file to be used for records
StreamReader recordRead = new StreamReader(recFile);
String recordss = recordRead.ReadToEnd(); //Reads Record file
recordRead.Close();
recFile.Close();
Byte [] arr=Encoding.UTF8.GetBytes(recordss) ;
FileStream file = new FileStream("Temp.txt", FileMode.Create, FileAccess.Write);
StreamWriter binfile = new StreamWriter(file);
for(int i =0; i < arr.Count();i++)
binfile.WriteLine(arr[i]);
binfile.Close();
file.Close();
}