C# OpenFileDialog用法

weixin_34104341發表於2020-04-07

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);
       }
}

轉載於:https://www.cnblogs.com/huangbingzhi/p/4836725.html

相關文章