C#读取、保存二进制数据文件

保存二进制数据文件

            FileStream fs = new FileStream(sFileName, FileMode.OpenOrCreate);
            BinaryWriter binWriter = new BinaryWriter(fs);

            binWriter.Write(labelContent, 0, labelContent.Length);

            binWriter.Close();
            fs.Close();


读取二进制数据文件

            byte[] bBuffer;

            FileStream fs = new FileStream(sFileName, FileMode.Open);
            BinaryReader binReader = new BinaryReader(fs);

            bBuffer = new byte[fs.Length];
            binReader.Read(bBuffer, 0, (int)fs.Length);

            binReader.Close();
            fs.Close();


你可能感兴趣的:(.Net)