C# OpenFileDialog用法

private void button1_Click(object sender, EventArgs e)
{
      OpenFileDialog fileName = new OpenFileDialog();
      fileName.InitialDirectory = Application.StartupPath;
      fileName.Filter = "所有文件(*.*)|*.*|菜单文件(*.md)|*.md";
      fileName.FilterIndex = 2;
      fileName.RestoreDirectory = true;
      if (fileName.ShowDialog() == DialogResult.OK) {
               //MessageBox.Show(fileName.FileName);
              //Stream stream=fileName.OpenFile();
              //StreamReader sr = new StreamReader(stream);
             //BinaryReader br = new BinaryReader(stream, Encoding.Unicode);
       }
}

posted on 2015-09-24 22:12  nealin  阅读(348)  评论(0编辑  收藏  举报

导航