C#winform中OpenFileDialog的用法

时间:2014-06-02 21:47:55   收藏:0   阅读:411
bubuko.com,布布扣
private void btnOpenFileDialog_Click(object sender, EventArgs e)
        {
            OpenFileDialog oFD = new OpenFileDialog();
            oFD.Title = "打开文件";
            oFD.ShowHelp = true;
            oFD.Filter = "文本文件|*.txt|RTF文件|*.rtf|所有文件|*.*";//过滤格式
            oFD.FilterIndex = 1;                                    //格式索引
            oFD.RestoreDirectory = false;
            oFD.InitialDirectory = "c:\\";                          //默认路径
            oFD.Multiselect = true;                                 //是否多选
            if (oFD.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show(oFD.FileName);
                MessageBox.Show(oFD.FileNames[0]);
                MessageBox.Show(oFD.SafeFileName);
                MessageBox.Show(oFD.SafeFileNames[0]);
            }

        }
bubuko.com,布布扣

 

C#winform中OpenFileDialog的用法,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!