C# Get Files Greater than Specific Size using Linq
C# and LINQ can be combined to do wonders; here is a sample of that. The following snippet extracts the files that are more thsn 345 KB
private static void GetFilesFromDirectory(string DirPath)
{
try
{
DirectoryInfo Dir = new DirectoryInfo(DirPath);
FileInfo[] FileList = Dir.GetFiles("*.*", SearchOption.TopDirectoryOnly );
var query = from FI in FileList
where FI.Length > 340000
select FI.FullName + " " + FI.Length.ToString() ;
foreach (string s1 in query )
{
Console.WriteLine(s1);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message );
}
}
Extract files based on Size in C#, Extract files greater than 1GB using C#, C# List files based on Size, Filter by FileSize using C#, Extract files based on Size in .NET, Extract files greater than 1GB using .NET, .NET List files based on Size,
No comments:
Post a Comment