实现效果:

  

知识运用:

  OpenFileDialog组件的Multiselect属性  //是否允许多选

  public bool Multiselect {get;ser;}

  FileNames属性    //获取所有选定的文件的文件名

  public string[] FileName {get;}

实现代码:

        private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "txt文件(*.txt)|*.txt";
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string Content = string.Empty;
foreach(string s in openFileDialog1.FileNames) //注意是s
{
StreamReader sr = new StreamReader(s,Encoding.Default);
Content += sr.ReadToEnd();
sr.Close();
}
textBox1.Text = Content;
}
}

最新文章

  1. Startup配置类 居然又是约定
  2. 设置apache https服务
  3. ReactiveCocoa信号使用方法
  4. [Java] Java中List 去掉重复的值,并保持原先List顺序
  5. Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
  6. 【Android 界面效果24】Intent和PendingIntent的区别
  7. Java-20个非常有用的程序片段
  8. QT国际化
  9. 《Getting Started with WebRTC》第一章 WebRTC介绍
  10. CentOS上安装WordPress搭建博客平台
  11. VS2017 连接Linux
  12. 2018牛客网暑期ACM多校训练营(第一场)J Different Integers(树状数组)
  13. VMware5.5-VMware补丁程序VUM
  14. log4net写入日志到sqlserver数据库
  15. 转 安装Nginx 1.2.0+PHP 5.4.3(FastCGI)+MySQL 5.5.24
  16. ajax post方式下载后台传来的文件
  17. no matching function for call to ‘std::basic_string<char>::assign(std::string&, int)
  18. 自增ID时如何插入ID
  19. 一行代码彻底禁用WordPress缩略图自动裁剪功能
  20. 使用python创建生成动态链接库dll

热门文章

  1. Exception异常处理
  2. FoundToday for HK 技术支持
  3. PAT甲级——1101 Quick Sort (快速排序)
  4. Ubuntu下rsyslog审计用户bash操作命令、收集、写入MySQL
  5. Java中keytool管理证书
  6. LDAP相关操作注意事项
  7. Oracle存储过程实例分析总结(代码)
  8. 002 Add Two Numbers 链表上的两数相加
  9. Problem Statement
  10. sourceInsight4 破解笔记(完美破解)