日期:2014-05-17 浏览次数:21230 次
public static string GetStringX(byte[] source)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < source.Length; i++)
{
sb.Append(source[i].ToString("x2"));
sb.Append(" ");
}
return sb.ToString();
}
private static void Write(byte[] bytContents)
{
int length = bytContents.Length;
StringBuilder builder = new StringBuilder(length * 3);
foreach (byte value in bytContents)
{
builder.AppendFormat("{0:X} ", value);
}
System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\test.txt",false, System.Text.Encoding.Default);
sw.Write(builder.ToString());
sw.Close();
}
private static byte[] Read(string strFile)
{
System.IO.StreamReader sr = new System.IO.StreamReader(strFile, System.Text.Encoding.Default);
string strContent = sr.ReadToEnd();
sr.Close();
string[] arry = strContent.Split(' ');
List<byte> lstRet=new List<byte> ();
foreach (string s in arry)
{
&nb