文本转化成十六进制

Byte[] byteArray = System.IO.File.ReadAllBytes( " k:\\photo.jpg " );
StringBuilder HexStringBuffer
= new StringBuilder();
foreach ( byte b in byteArray)
{
  HexStringBuffer.Append(b.ToString(
" X2 " ) + " " );
}
String hexString
= HexStringBuffer.ToString();
hexString
= hexString.Trim();

你可能感兴趣的:(c#学习日记,.NET,byte,string)