NoviceMe
NoviceMe

Reputation: 3256

Get file with particular extension and check the size of the file

I am trying to go into a folder and look for files with extension .abc, these files will come and go in this folder but what i want to know is if this file exists and size of the file is greater than 50kb then i should be notified. I have this code:

if(File.Exists(@"c:\home\myfolder\*.abc"))
{

}

I dont think putting an * will get me files with extension .abc, does anyone know how i can achieve this and get the size of the file if it exists?

Upvotes: 0

Views: 492

Answers (1)

Igor
Igor

Reputation: 15893

string[] files = System.IO.Directory.GetFiles(@"c:\home\myfolder", "*.abc");
if (files.Length > 0)
{
}

Upvotes: 3

Related Questions