zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    标准I/O的缓冲
    Linux 的文件类型
    引用和指针
    信号-总结
    实时信号
    信号的其它特性
    信号处理器函数
    信号集 / 信号掩码(阻塞信号传递)
    显示信号描述
    发送信号
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/5537811.html
Copyright © 2011-2022 走看看