FileSize

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());

Description

Get the file size of a given filename.

Details

Double click on the code to select all.

 

;