Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
Enable button on only text file select
Aniruddha Acharya
Nov 20 2017 11:44 PM
174
Reply
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.
}
}
Only for select .txt file . if other any file [.ppt,pdf,...etc] then disabled this button
Thanks
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
How to access android Mobile camera on internet ?
Getting response "System.Net.HttpStatusCode.Unauthorized"