我有一个十六进制文件abc.aa
用编辑器查看是如下
03 00 00 00 01 07 48 56 37 0c 00 16 22 06 0b 0c
00 04 00 4d 65 6e 75 7c 02 00 00 0a 00 4f 62 6a我想把这些编码存储到aa.txt 文件中
格式如下
0300000001074856370c001622060b0c0004004d656e757c0200000a004f626a我做的"03""04""0A"都会自动变成“3”"4" "a"
用编辑器查看是如下
03 00 00 00 01 07 48 56 37 0c 00 16 22 06 0b 0c
00 04 00 4d 65 6e 75 7c 02 00 00 0a 00 4f 62 6a我想把这些编码存储到aa.txt 文件中
格式如下
0300000001074856370c001622060b0c0004004d656e757c0200000a004f626a我做的"03""04""0A"都会自动变成“3”"4" "a"
{
fs.Seek(-1, SeekOrigin.End);
int b = fs.ReadByte();
}
FileStream fs = new FileStream("d:\\abc.aa", FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
StreamWriter sw = new StreamWriter("d:\\aa.txt");
int length = (int)fs.Length;
while (length > 0)
{
byte tempByte = br.ReadByte();
string tempStr = Convert.ToString(tempByte, 16);
sw.WriteLine(tempStr);
length--;
}
fs.Close();
br.Close();
sw.Close();
但是保存出来的TXT中的的"03""04""0A"都会自动变成“3”"4" "a"
前面加上:
if (temStr.Length == 1) temStr = "0" + temStr;
但是现在txt中是这样的
03
00
00
10
74
85
6a我想要的是
0300001074856a
你不能那么机械