标签:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO;//导入命名空间 namespace WindowsFormsApplication4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } private void 查找ToolStripMenuItem_Click(object sender, EventArgs e) { } private void 剪切TToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.Cut(); } private void 复制CToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.Copy(); } private void 粘贴PToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.Paste(); } private void 全选AToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.SelectAll(); } private void 撤消UToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.Undo(); } private void 打开OToolStripMenuItem_Click(object sender, EventArgs e) { //创建打开文件对话框:实现硬盘上查找文件路径 // OpenFileDialog openfiledialong1=new OpenFileDialog();//创建对象 //可以在界面上造一个openfiledialog对象F大写 openFileDialog1.Filter = "文本文档|*.txt|所有文件|*.*";//过滤 DialogResult isok = openFileDialog1.ShowDialog(); //显示对话框 枚举类型的返回值 if (isok == DialogResult.OK)//来通过对话框的返回值判断是否点的打开 { //获取文件路径 string filename = openFileDialog1.FileName; //根据文件路径读取文件:使用流来读取 流:专门用于内盘跟英寸去交互、读写的 //FileStream fs = new FileStream(filename,FileMode.Open ); //StreamReader sr = new StreamReader(fs,Encoding.Default);//流读取器 StreamReader sr = new StreamReader(filename, Encoding.Default); string text = sr.ReadToEnd();//读取 sr.Close(); // fs.Close(); textBox1.Text = text; } } } }
标签:
原文地址:http://www.cnblogs.com/zhuxu/p/4966723.html