I'm trying to read a plain text file (.txt) on Windows using C# into a byte array with base16 encoding. This is what I've got:
FileStream fs = null;
try
{
fs = File.OpenRead(filePath);
byte[] fileInBytes = new byte[fs.Length];
fs.Read(fileInBytes, 0, Convert.ToInt32(fs.Length));
return fileInBytes;
}
finally
{
if (fs != null)
{
fs.Close();
fs.Dispose();
}
}
When I read a txt file with this content: 0123456789ABCDEF
I get a 128 bits (or 16 bytes) array but what I wanted is a 64 bits (or 8 bytes) array.
How can I do this?