Let us see a simple code using LINQ and C# that calculates the average FileSize of the files kept in a folder.
First import the following namespaces:
using System.Linq;
using System.IO;
Then write the following code:
class Program
{
static void Main(string[] args)
{
string[] dirfiles = Directory.GetFiles(“c:\\software\\”);
var avg = dirfiles.Select(file =>