How to get file extension from path in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "d:\\data.txt";

            string extension = Path.GetExtension(s);

            Console.WriteLine(extension);
        }
    }
}


/*
run:
  
.txt

*/

 



answered Aug 16, 2018 by avibootz

Related questions

2 answers 268 views
1 answer 233 views
1 answer 111 views
1 answer 403 views
1 answer 262 views
...