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 WindowsFormsApplication5
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "文本文件|*.txt|所有文件|*.*";
DialogResult isok= openFileDialog1.ShowDialog();
if (isok == DialogResult.OK)
{
string filename = openFileDialog1.FileName;
StreamReader sr = new StreamReader(filename,Encoding.Default);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult isok= saveFileDialog1.ShowDialog();
if (isok == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
StreamWriter sw = new StreamWriter(filename);
sw.Write(textBox1.Text);
sw.Close();
}
}
}
}