December 20th, 2012, 02:22 PM
FileInfo filter by size
Hey, I'm a fairly new programmer and currently working on a University assignment and theres an extra feature I want to implement but can't seem to work it out
I have these two lines at the start of my program
DirectoryInfo folderInfo = new DirectoryInfo(C:\\Windows);
FileInfo files = folderInfo.GetFiles();
but I've been trying to create a new FileInfo array that will only contain files from DirectoryInfo if the file size is within a certain range of a user inputted value
Someone recommended I use a where command which I haven't been taught yet, and searching online hasn't helped much and I just ended up with a line like
FileInfo sizeFiltered = fileArray.Where(f => f.Length >= lowerBound && f.Length <= upperBound)
which made my compiler angry.
Any help on fixing my problem would be greatly appreciated
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!