二进制及十进制文件的读写方法

//二进制读

void HexAnalysis(string fileName)
        {
            string s = "";
            StreamReader f2 = new StreamReader(fileName, System.Text.Encoding.GetEncoding("gb2312"));
            s = f2.ReadToEnd();
            f2.Close();
            f2.Dispose();
        }

//十进制

byte[] data = new byte[tagLength];
        using (var stream = File.OpenRead(file))
        {
            stream.Seek(-1 * tagLength, SeekOrigin.End);
            stream.Read(data, 0, data.Length);
        }

 

posted @ 2016-04-08 16:31  qq921201008  阅读(371)  评论(0编辑  收藏  举报