programming-examples/c-sharp/Linq/C# Program to Calculate Size of File using LINQ.cs
2019-11-15 12:59:38 +01:00

20 lines
501 B
C#

/*
* C# Program to Calculate Size of File using LINQ
*/
using System;
using System.Linq;
using System.IO;
class Program
{
static void Main(string[] args)
{
string[] dirfiles = Directory.GetFiles("c:\\sri\\");
var avg = dirfiles.Select(file =>new FileInfo(file).Length).Average();
avg = Math.Round(avg / 10, 1);
Console.WriteLine("The Average file size is {0} MB",avg);
Console.ReadLine();
}
}
/*
The Average file size is 8.8 MB