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 259 views
1 answer 226 views
1 answer 102 views
1 answer 397 views
1 answer 253 views
...