help
josee 2004-03-05 07:33:45 各位大侠
小弟有一问题,请求解决
我用BinaryReader读写二进制文件,当读到8655个float数据时,出现异常,异常信息message是转换缓冲区溢出,二进制数据只能读到此处,请各位大侠帮忙啊
源程序如下:
OpenFileDialog dd=new OpenFileDialog();
dd.Title="获取数据文件";
dd.Filter="二进制文件(*.bin)|*.bin|所有文件 (*.*)|*.*";
ArrayList array_list=new ArrayList();
if(dd.ShowDialog()==DialogResult.OK)
{
System.IO.FileInfo f=new FileInfo(dd.FileName);
System.IO.BinaryReader br=new System.IO.BinaryReader(f.OpenRead());
int pos=0;
try{
while (br.PeekChar()!=-1)
{
array_list.Insert(pos,br.ReadSingle());
++pos;
}
br.Close();
}
catch(System.ArgumentException e)
{MessageBox.Show(e.Message+pos.ToString(),"ni");}
}
return array_list;