Click here to Skip to main content
14,698,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code created for net framework 4.5, is it possible to work with framework version 2.0 on windows 2000? If not how to do same things (count files with extension of .dat with size of maximum 300kb)?
public void Form1_Load(object sender, EventArgs e)

           DirectoryInfo dir = new DirectoryInfo(@"C:/a");
           int fileCount = dir.GetFiles("*.dat").Where(m => (m.Length / 1024) > 285).Count();

textBox1.Text = fileCount.ToString();

1 solution

It's only the Linq-based Where you can't use so use a loop instead

DirectoryInfo dir = new DirectoryInfo(@"C:/a");
int fileCount = 0;
foreach (FileInfo file in dir.GetFiles("*.dat"))
    if ((file.Length / 1024) > 258)


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900