If you want to get the file's size , you can use FileInfo.Length; for instance:// The following example displays the names and sizes // of the files in the specified directory. using System; using System.IO;public class FileLength { public static void Main() { // Make a reference to a directory. DirectoryInfo di = new DirectoryInfo("c:\\"); // Get a reference to each file in that directory. 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("The size of {0} is {1} bytes.", f.Name, f.Length); } }
for instance:// The following example displays the names and sizes
// of the files in the specified directory.
using System;
using System.IO;public class FileLength
{
public static void Main()
{
// Make a reference to a directory.
DirectoryInfo di = new DirectoryInfo("c:\\");
// Get a reference to each file in that directory.
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("The size of {0} is {1} bytes.", f.Name, f.Length);
}
}