请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册
查看: 10835|回复: 1

选择一个文件

[复制链接]

1288

主题

1514

帖子

90

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22589
发表于 2019-5-11 18:56:10 | 显示全部楼层 |阅读模式
  1. OpenFileDialog openFileDialog1 = new OpenFileDialog();
  2.             openFileDialog1.Filter = "JPEG文件|*.jpg*|BMP文件|*.bmp*|TIFF文件|*.tiff*";
  3.             openFileDialog1.RestoreDirectory = true;
  4.             openFileDialog1.FilterIndex = 1;
  5.             if (openFileDialog1.ShowDialog() == DialogResult.OK)
  6.             {
  7.                 string ImagePath;
  8.                 ImagePath = openFileDialog1.FileName;
  9.                 HD.action(hWindowControl2.HalconWindow, ImagePath);
  10.             }
复制代码


算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

1288

主题

1514

帖子

90

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22589
 楼主| 发表于 2021-12-16 15:47:40 | 显示全部楼层
  1.             OpenFileDialog openFileDialog1 = new OpenFileDialog();
  2.             openFileDialog1.Filter = "所有文件|*.**";
  3.             openFileDialog1.Filter = "All files (*.*)|*.*";
  4.             if (this.chB_txt.Checked==true)
  5.             {
  6.                 openFileDialog1.Filter = "txt files (*.txt)|*.txt";
  7.             }
  8.             else if (this.chB_doc.Checked == true)
  9.             {
  10.                 openFileDialog1.Filter = "doc files (*.doc)|*.doc";
  11.             }
  12.             else if (this.chB_docx.Checked == true)
  13.             {
  14.                 openFileDialog1.Filter = "docx files (*.docx)|*.docx";
  15.             }
  16.             else if (this.chB_csv.Checked == true)
  17.             {
  18.                 openFileDialog1.Filter = "csv files (*.csv)|*.csv";
  19.             }
  20.             else if (this.chB_xls.Checked == true)
  21.             {
  22.                 openFileDialog1.Filter = "xls files (*.xls)|*.xls";
  23.             }
  24.             else if (this.chB_xlsx.Checked == true)
  25.             {
  26.                 openFileDialog1.Filter = "xlsx files (*.xlsx)|*.xlsx";
  27.             }
  28.             else if (this.chB_xml.Checked == true)
  29.             {
  30.                 openFileDialog1.Filter = "xml files (*.xml)|*.xml";
  31.             }
  32.             openFileDialog1.FilterIndex = 1;
  33.             openFileDialog1.RestoreDirectory = true;
  34.             if (openFileDialog1.ShowDialog() == DialogResult.OK)
  35.             {
  36.                 string filename = openFileDialog1.FileName;
  37.                 this.tB_FilePath.Text = filename.ToString();
  38.                 this.button1.Enabled = true;
  39.                 this.button2.Enabled = true;
  40.             }
复制代码
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-3-29 18:41 , Processed in 0.189324 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表