OpenFileDialog Ofg = new OpenFileDialog (); Ofg. title = "DDD";//Set Dialog Caption Ofg. MultiSelect = true;//The Settings dialog box allows you to select multiple ofg. InitialDirectory =;//Set the initial directory Ofg of the dialog box . Filter =//Set file type Ofg. ShowDialog (); String path = Ofg. FileName; if (Path = = "") { return; } using (FileStream isread = new FileStream (path,filemode.openorcreate,fileaccess.read)) { byte[] buffer = new BYTE[1024*1024*5]; Sets the number of bytes read to int r = isread. Read (Buffer,0,buffer. Length); TextBox1.Text = Encoding.Default.GetString (buffer,0,r); }
Small knowledge Point: combobox. Items.clear () name: CBO .... SelectedIndexChanged combobox.selectitem.tostring () comboBox1.SelectedItem.ToString (). Split (new char[] {' Month '}, stringsplitoptions.removeemptyentries); ListBox: Direct Item or code Add Item listbox.selectedindex listbox_doubleclick path. GetFileName Double-click to play Music: SoundPlayer sp = new SoundPlayer (); Sp. Soundlocation = ... Sp. Play ();
WinForm Learning----Open a File dialog box and place the contents of the file in a text box