C# FileInfo Length

Description

FileInfo Length Gets the size, in bytes, of the current file.

Syntax

FileInfo.Length has the following syntax.


public long Length { get; }

Example

Gets the size, in bytes, of the current file.


using System;/*from  ww  w .j  a  v  a  2  s .c o  m*/
using System.IO;

public class DirectoryTest 
{
    public static void Main() 
    {
        FileInfo fi = new FileInfo("temp.txt");

        Console.WriteLine(fi.Length);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter