Output:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Question_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
FileStream fs;
BinaryReader br;
BinaryWriter bw;
//For Read
private void button1_Click(object sender, EventArgs e)
{
fs = new FileStream("Test.txt", FileMode.Open);
br =new BinaryReader(fs);
Object ob;
ob = br.ReadString();
textBox1.Text = ob.ToString();
br.Close();
fs.Close();
}
//For write
private void button2_Click(object sender, EventArgs e)
{
fs = new FileStream("Test.txt", FileMode.Create);
bw = new BinaryWriter(fs);
bw.Write(textBox1.Text);
bw.Close();
fs.Close();
}
//For clear
private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
}
}
}
No comments:
Post a Comment