我需要读取二进制文件。但是得到了错误。我该怎么做呢?我在试着解释我还能写什么?
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‘是一个'namespace’,但它的用法与'type‘类似
我怎么才能修复它?
发布于 2012-08-16 09:57:08
您的名称与您自己的名称空间冲突。例如,将其重命名为BinaryReaderTest,或者对System.IO的BinaryReader类使用System.IO.BinaryReader的全名:
using (var br = new System.IO.BinaryReader(File.Open("file.bin", FileMode.Open)))https://stackoverflow.com/questions/11979692
复制相似问题