C# 选择文件对话框(转自:http://blog.csdn.net/longest9/article/details/1567929)

 OpenFileDialog fileDialog1 = new OpenFileDialog();
            fileDialog1.InitialDirectory = "d://";
            fileDialog1.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
            fileDialog1.FilterIndex = 1;
            fileDialog1.RestoreDirectory = true;
            if (fileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = fileDialog1.FileName;
            }
            else
            {
                textBox1.Text = "";

            } 

注意,xls files (*.xls)|*.xls是成对出现的,前者用于描述,后者用于筛选。

你可能感兴趣的:(C#,textbox)