你这个是,读取一个二进制的文件?
把二进制的文件内容,转成string类型的内容?
using (FileStream stream = File.OpenRead(@"路径"))
{
byte[] content = new byte[stream.Length];
for (int i = 0; i < content.Length; i++)
{
content[i] = (byte)stream.ReadByte();
}
Console.WriteLine(Encoding.Default.GetString(content));
}
public string ByteToString(byte[] inputBytes)
{
StringBuilder temp = new StringBuilder(2048);
foreach (byte tempByte in inputBytes)
{
temp.Append(tempByte > 15 ?
Convert.ToString(tempByte, 2) : '0' + Convert.ToString(tempByte, 2));
}
return temp.ToString();
}
用convert.tostring方法```