Hi,
I want to how to enabled button when only select .txt file from browse openFileDialog window .
I am using this code on browse button click .
private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.DefaultExt = ".txt";
openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
result = openFileDialog.Filter;
if (openFileDialog.ShowDialog() == true) //Open file dialog window
{
txtpath = openFileDialog.FileName;
FileNameTextBox.Text = txtpath;
btnCompaire.IsEnabled = true; openFileDialog.
}
}
{
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.DefaultExt = ".txt";
openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
result = openFileDialog.Filter;
if (openFileDialog.ShowDialog() == true) //Open file dialog window
{
txtpath = openFileDialog.FileName;
FileNameTextBox.Text = txtpath;
btnCompaire.IsEnabled = true; openFileDialog.
}
}
Only for select .txt file . if other any file [.ppt,pdf,...etc] then disabled this button
Thanks

Ramesh PalanivelRank #372 · 6.8K reputationPosted Nov 20, 2017, 8:42 PM EST
Aniruddha AcharyaRank #8,429 · 222 reputationPosted Nov 20, 2017, 11:13 PM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Nov 20, 2017, 11:20 PM EST
{
Aniruddha AcharyaRank #8,429 · 222 reputationPosted Nov 20, 2017, 11:23 PM EST