Windows Phone Developers

Saturday, November 1, 2008

C# Get Files Greater than Specific Size using Linq

List files based on FileSize using C#

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, Filter by FileSize using .NET, Extract files based on Size in LINQ , Extract files greater than 1GB using LINQ , LINQ List files based on Size, Filter by FileSize using LINQ

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment