OpenFileDialog打开cmd,txt文件并读入textbox中

OpenFileDialog打开cmd,txt文件并读入textbox中
        private void 导入模板ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = " 请选择您要导入的模板文件:";
            ofd.Filter = "TextDocument(*.cmd)|*.cmd|TextDocument(*.txt)|*.txt";
            ofd.ShowDialog();
            System.IO.StreamReader sr = new System.IO.StreamReader( ofd.FileName ,System.Text.Encoding.Default);
            txtCmdInput.Text = sr.ReadToEnd();
        }

你可能感兴趣的:(OpenFileDialog打开cmd,txt文件并读入textbox中)