• winform学习之----打开文件对话框并将文件内容放入文本框


                OpenFileDialog ofg = new OpenFileDialog();
                ofg.Title = "ddd";//设置对话框标题
                ofg.Multiselect = true;//设置对话框可以多选
                ofg.InitialDirectory = ;//设置对话框的初始目录
                ofg.Filter = //设置文件类型
                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];
                    //设置读取到的字节数
                  int r = isread.Read(buffer,0,buffer.Length);
                  textbox1.text = Encoding.Default.GetString(buffer,0,r);
                }
    

    小知识点: combobox.Items.clear() 命名:cbo.... selectedindexchanged combobox.selectitem.tostring() comboBox1.SelectedItem.ToString().Split(new char[] { '月' }, StringSplitOptions.RemoveEmptyEntries); listbox:直接项或者代码加项 listbox.selectedindex listbox_doubleclick path.GetFileName 双击播放音乐: SoundPlayer sp = new SoundPlayer(); sp.SoundLocation = ... sp.Play();
  • 相关阅读:
    复变函数
    abc136
    点集
    一些数学题
    牛客多校第六场
    牛客多校第五场G
    复数
    generator 1
    digits 2
    Winner
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/5537811.html
Copyright © 2020-2023  润新知