Declaration Part: public static int chknofiles;
Function Part: public static bool chkfileextention(string filepath, string fileextension)
{
string[] fsDir = Directory.GetFiles(filepath);
foreach (string f in fsDir)
{
string fName = f.Substring(filepath.Length + 1);
string[] fileExt = fName.Split('.');
if (fileExt[1] == fileextension)
{
chknofiles = chknofiles + 1;
}
}
if (chknofiles > 1)
{
chkfileextension = true;
}
else
{
chkfileextension = false;
}
return chkfileextension;
}
Coding Part: bool chk = chkfileextention(txtBrowsFile.Text, "pcl");
if (chk)
{
MessageBox.Show("true");
}
else
{
MessageBox.Show("false");
}