1.
Build your form
You need textbox, two Buttons,
Savefiledialog and OpenFile Dialog .
And make the text box MULTI LINE
Add a string variable “name” (this
must be public)
public partial class Form1 : Form
{
string name;
public Form1()
{
InitializeComponent();
}
Add a namespace System.IO;
using System.IO;
1. Write
tis code for Open button
Add a string variable
“name” that means the file name.
string name;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
name = openFileDialog1.FileName;
textBox1.Clear();
textBox1.Text = File.ReadAllText(name);
}
2. Now
write this code for SAVE button
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
name = saveFileDialog1.FileName;
File.WriteAllText(name, textBox1.Text);
}
3.
Now you are done.
0 comments:
Post a Comment