什么叫16进制读取文件阿?听着别扭。下面的例子也许能帮助你:
static void Main(string[] args)
{
FileStream fs = new FileStream("..\\..\\test.txt",FileMode.Open,FileAccess.Read);
BinaryReader br = new BinaryReader((Stream)fs);
byte[] buffer = new byte[1024];//只读取了1024个字节,请自己完善
int count = br.Read(buffer,0,1024);
for (int i=0;i<count;i++)
{
Console.Write("{0}{1} ",HighHex(buffer[i]),LowHex(buffer[i]));
} br.Close();
fs.Close();
} static char HighHex(byte b)
{
b = (byte)(b >> 4);
if (b < 10)
{
return (char)(b+48);
}
else
{
return (char)(b+87);
}
} static char LowHex(byte b)
{
b = (byte)(b & 0x0F);
if (b < 10)
{
return (char)(b+48);
}
else
{
return (char)(b+87);
}
}
}

解决方案 »

  1.   

    StreamReader srReadLine = new StreamReader(
                (System.IO.Stream)File.OpenRead("C:\\Temp\\Test.txt"),
             System.Text.Encoding.ASCII);
             srReadLine.BaseStream.Seek(0, SeekOrigin.Begin);
             while (srReadLine.Peek() > -1) {
                Console.WriteLine(srReadLine.ReadLine().ToString("x"));
             }
             srReadLine.Close();
    没有验证过,我想应该可以吧。
                                                                    祝好运
                                                                    接分
      

  2.   

    谢谢上面的快乐鸟兄,你的方法可以用~~ istring()兄的方法行不通,不过还是要谢谢~!