Winfrom Text Document Open

Source: Internet
Author: User

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;//            Import namespace namespace windowsformsapplication4{public partial class Form1:form {public Form1 () {        InitializeComponent (); private void Form1_Load (object sender, EventArgs e) {} private void Statusstrip1_itemclicke D (object sender, ToolStripItemClickedEventArgs e) {} private void Lookup Toolstripmenuitem_click (object s            Ender, EventArgs e) {} private void cut Ttoolstripmenuitem_click (object sender, EventArgs e) {        Textbox1.cut ();        } private void Copy Ctoolstripmenuitem_click (object sender, EventArgs e) {textbox1.copy (); } private void Paste Ptoolstripmenuitem_click (object sender, EventArgs e) {TexTbox1.paste ();        } private void Select all Atoolstripmenuitem_click (object sender, EventArgs e) {textbox1.selectall ();        } private void Undo Utoolstripmenuitem_click (object sender, EventArgs e) {Textbox1.undo (); } private void opens Otoolstripmenuitem_click (object sender, EventArgs e) {//Create Open File dialog box: Implement find text on hard disk            Path//OpenFileDialog openfiledialong1=new OpenFileDialog ();//Create object//You can build a OpenFileDialog object in the interface F caps  Openfiledialog1.filter = "Text document |*.txt| all Files |*.*";//filter DialogResult isOK = Openfiledialog1.showdialog ();                Displays the return value of the dialog enumeration type if (isOK = = DialogResult.OK)//To determine if the point is opened by the return value of the dialog box {//Get file path                string filename = Openfiledialog1.filename;                Read files based on file path: stream is used to read the stream://filestream fs = new FileStream (Filename,filemode.open) that is specifically used for internal disks and inches to interact, read and write; StreamReader sr = new StreamReader (fs,encoding.dEfault);//Stream reader StreamReader sr = new StreamReader (filename, encoding.default); String text = Sr. ReadToEnd ();//Read Sr.               Close (); Fs.                Close ();            TextBox1.Text = Text; }        }    }}

  

Winfrom Text Document Open

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.