我需要读取二进制文件。但是出现错误。我该怎么做 ?我试图解释我还能写什么?
using System;
using System.IO;
using System.Net;
using System.Text;
namespace BinaryReader
{
public partial class Form1 : Form1
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void R()
{
using (BinaryReader br = new BinaryReader(File.Open("file.bin", FileMode.Open)))
{
// 2.
// Position and length variables.
int pos = 0;
// 2A.
// Use BaseStream.
int length = (int)b.BaseStream.Length;
while (pos < length)
{
// 3.
// Read integer.
int v = b.ReadInt32();
Console.WriteLine(v);
// 4.
// Advance our position variable.
pos += sizeof(int);
}
}
}
}
}
在这一行我得到错误:
using (BinaryReader br = new BinaryReader(File.Open("file.bin", FileMode.Open)))
错误“BinaryReader”是“命名空间”,但用作“类型”
我该如何解决?