Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

1.

C# Program to Calculate Size of File using LINQ


This C# Program Calculates Size of File using LINQ. Here the size of the folder is found using
LINQfunctions.
Here is source code of the C# Program to Calculate Size of File using LINQ. The C#
program is successfully compiled and executed with Microsoft Visual Studio. The
program output is also shown below.
/*

1.
2.

* C# Program to Calculate Size of File using LINQ

3.

*/

4.

using System;

5.

using System.Linq;

6.

using System.IO;

7.

class Program

8.

9.

static void Main(string[] args)

10.

11.

string[] dirfiles = Directory.GetFiles("c:\\sri\\");

12.

var avg = dirfiles.Select(file =>new


FileInfo(file).Length).Average();

13.

avg = Math.Round(avg / 10, 1);

14.

Console.WriteLine("The Average file size is {0} MB",avg);

15.

Console.ReadLine();
}

16.
17.

You might also like