private void Button3_Click(object sender, System.EventArgs e)
{
//写二进制文件
BinaryWriter bw;
//创建一个二进制文件
FileStream fs=new FileStream (MapPath("mydata.data"),FileMode.Create );
bw=new BinaryWriter (fs);//初始化一个BinaryWriter
for(int i=0;i<200;i++)
bw.Write (i);//写入
bw.Close ();//关闭
}
private void Button4_Click(object sender, System.EventArgs e)
{
//读二进制文件
BinaryReader br;
string str="";
FileStream fs=new FileStream (MapPath("mydata.data"),FileMode.Open );
br=new BinaryReader (fs);
for(int i=0;i<fs.Length /4;i++)
str+=br.ReadInt32 ().ToString ();
TextBox1.Text =str;
}
本文地址:http://com.8s8s.com/it/it43413.htm