How to Get File Size in C#/CSharp

To get file size in C#/CSharp, we make use FileInfo class which resides in System.IO namespace.  Example is given below:

using System;
using System.IO;

namespace Hello_World
{

    class Program
    {
        static void Main(string[] args)
        {
            long filesize = new FileInfo("filname.txt").Length;
            Console.WriteLine(filesize);
        }
    }
}

 

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •