" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi
The following code can be used to extract files that are greater than 1MB under any specific directory (using LINQ).
private static void GetFiles(string Path)
DirectoryInfo directory = new DirectoryInfo(Path);
FileInfo files = directory.GetFiles("*.*", SearchOption.AllDirectories);
var query = from file in files
where file.Length > 1024*1024
select "File Name:"+ file.Name + " File Size: " + file.Length.ToString();
foreach (string str in query)
catch (Exception ex)
– Call the above defined function in Main() like
It will return all files that are greater than 1 MB.
Mail (will not be published) (required)
Enter Captcha Code *
five + 4 =
Burn Ignorance is a knowledge initiative by Mindfire Solutions
Subscribe to our mailing list to get the updates to your email inbox...