DirectoryInfo / Name und Größe der Dateien

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Gibt die Größe der jeweiligen Dateien und deren namen aus die sich im angegebenen Ordner befinden:

C# Code:
using System.Collections.Generic; using System; using System.IO; using System.Text;   namespace ReadSize { class Program { static void Main(string[] args) { // Make a reference to a directory. DirectoryInfo di = new DirectoryInfo("C:\\Temp"); // Get a reference to each file in that directory and put it into an array. FileInfo[] fiArr = di.GetFiles(); // Display the names and sizes of the files. Console.WriteLine("The directory {0} contains the following files:", di.Name); foreach (FileInfo f in fiArr) Console.WriteLine("{1} bytes \t\t{0}", f.Name, f.Length); Console.WriteLine("Press any key"); Console.ReadKey(); } } }