FileSize
Get the file size of a given filename.
Source
public static long FileSize(this string filePath)
{
long bytes = 0;
try
{
System.IO.FileInfo oFileInfo = new System.IO.FileInfo(filePath);
bytes = oFileInfo.Length;
}
catch{}
return bytes;
}
Example
string path = @"D:\WWW\Proj\web.config";
Console.WriteLine("File Size is: {0} bytes.", path.FileSize());