拡張子が .txt のファイルを開くにはどうすればよいですか。ファイルが .txt ファイルでない場合、プログラムにエラー メッセージを表示させたいです。以下のコードを変更できるコードが必要です。
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
}
このループを入れたいとしましょう。
if fileextension is .txt then
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
else show error message(like can not open this file)