博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
winform openFileDialog的使用。
阅读量:7006 次
发布时间:2019-06-27

本文共 674 字,大约阅读时间需要 2 分钟。

代码如下:

 

ExpandedBlockStart.gif
View Code
 1 
 
private
 
void
 btnOpenFileDialog_Click(
object
 sender, EventArgs e)
 2 
        {
 3 
            OpenFileDialog oFD 
=
 
new
 OpenFileDialog();
 4 
            oFD.Title 
=
 
"
打开文件
"
;
 5 
            oFD.ShowHelp 
=
 
true
;
 6 
            oFD.Filter 
=
 
"
文本文件|*.txt|RTF文件|*.rtf|所有文件|*.*
"
;
//
过滤格式
 7 
            oFD.FilterIndex 
=
 
1
;                                    
//
格式索引
 8 
            oFD.RestoreDirectory 
=
 
false
;
 9 
            oFD.InitialDirectory 
=
 
"
c:\\
"
;                          
//
默认路径
10 
            oFD.Multiselect 
=
 
true
;                                 
//
是否多选
11 
            
if
 (oFD.ShowDialog() 
==
 DialogResult.OK)
12 
            {
13 
                MessageBox.Show(oFD.FileName);
14 
                MessageBox.Show(oFD.FileNames[
0
]);
15 
                MessageBox.Show(oFD.SafeFileName);
16 
                MessageBox.Show(oFD.SafeFileNames[
0
]);
17 
            }
18 
19 
        }

 

转载于:https://www.cnblogs.com/85538649/archive/2011/07/26/2116957.html

你可能感兴趣的文章