1. private void listBox1_DragEnter(object sender, DragEventArgs e)
  2. {
  3. if (e.Data.GetDataPresent(DataFormats.FileDrop))
  4. {
  5. e.Effect = DragDropEffects.Copy;
  6. }
  7. else
  8. {
  9. e.Effect = DragDropEffects.None;
  10. }
  11. }
  12.  
  13.  
  14. private void listBox1_DragDrop(object sender, DragEventArgs e)
  15. {
  16. string[] test = (string[])e.Data.GetData(DataFormats.FileDrop, false);
  17. //MessageBox.Show(test[0].ToString());
  18. Tps1.Clear();
  19. listBox1.Items.Clear();
  20. try
  21. {
  22. if (test[0].ToString().Contains(".txt"))
  23. {
  24. StreamReader sr1 = new StreamReader(test[0].ToString(), Encoding.UTF8);
  25. string line1;
  26. while ((line1 = sr1.ReadLine()) != null)
  27. {
  28. if (line1.Trim() == "")
  29. continue;
  30. Tps1.Add(line1);
  31. listBox1.Items.Add(line1);
  32. }
  33. sr1.Close();
  34. sr1.Dispose();
  35. }
  36. }
  37. catch { MessageBox.Show("文件不能识别!"); }
  38. }

最新文章

  1. Servlet基础(三) Servlet的多线程同步问题
  2. [转]关于信息安全认证CISP与CISSP的对比及分析
  3. ArcGIS发布地图服务
  4. POJ2406 Power Strings KMP算法
  5. Android中UI线程与后台线程交互设计的5种方法
  6. 监控mysql执行的sql语句
  7. String 的intern() 方法说明
  8. MessageBox, MessageBoxBurttons, MessageBoxIcon 详细解析
  9. iOS 9界面适配利器:详解Xcode 7的新特性UIStackView
  10. [Lua]Mac系统上安装Lua环境
  11. windows系统下安装composer
  12. oracle 权限
  13. JavaScript代码规范
  14. MySQL 5.7自定义安装图文详解
  15. 安装Python 3.6 在Ubuntu 16.04 LTS 版本
  16. C#泛型约束where T : class 解释
  17. LED类代码
  18. JavaScript -- Window-Resize
  19. Poly2Tri介绍[转]
  20. Nagios自定义扩展

热门文章

  1. Mysql自定义函数总结
  2. Debian下配置网络的方法
  3. 全半角空格导致的Sql Server Analysis Services处理错误(转载)
  4. 【海岛帝国系列赛】No.6 海岛帝国:战争前线
  5. SVN使用(二)
  6. Mongodb 笔记08 了解应用的动态、数据管理、持久性
  7. tp框架支付宝手机网页支付
  8. linux设备驱动归纳总结(六):1.中断的实现【转】
  9. Ubuntu检测磁盘是否挂载
  10. centos6.5-64bit安装htop