How to use C# BinaryReader Class
using System;
using System.Windows.Forms;
using System.IO;
using System.Text;
namespace WindowsApplication1
{
public
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FileStream readStream ;
string msg = null;
try
{
readStream = new FileStream("c:\\csharp.net-informations.dat",
FileMode.Open);
BinaryReader readBinary = new BinaryReader(readStream);
msg = readBinary.ReadString();
MessageBox.Show(msg);
readStream.Close();
}
catch (Exception ex)
{
MessageBox.Show (ex.ToString());
}
}
}
}
No comments:
Post a Comment