How to Get File Name from Path in C#/CSharp

To get file name from path in C#/CSharp, we make use of GetFileName() static method of Path 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)
        {
            string file = @"C:\Users\ADMIN\Desktop\delete.txt";
            string name = Path.GetFileName(file);

            Console.WriteLine(name);
        }
    }
}