Check Particulare file Format are in the Folder using C#.Net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 1554
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");
}

Comments or Responses

Login to post response