我正在加载文件到一个字节[]。据我了解,byte []应该包含字节的特定元素(8位)。当我打印每个字节时,它们都不是8位(即它们不具有8的长度)。 我的代码:C#问题与字节[]
FileStream stream = File.OpenRead(@"C:\Image\Img.jpg");
byte[] fileByte = new byte[stream.Length];
stream.Read(fileByte, 0, fileByte.Length);
for (int i = 0; i <= fileByte.Length - 1; i++)
{
Console.WriteLine(Convert.ToString(fileByte[i], 2));
}
输出:
10001110
11101011
10001100
1000111
10011010
10010011
1001010
11000000
1001001
100100
我觉得我的理解是错在这里,你能请让我知道(或提供我一些教程链接),我很想念这个。
'字节[]数据= File.ReadAllBytes(@ “FilePath.jpg”);' – 2009-10-29 15:53:57