This example shows you How to use C# Path Class. The Path class provides static methods that help you get the directory name, file extension , file name or current application path...etc.

string path = "c:\\dotnet.txt";
string fileExtension = Path.GetExtension(path);
string fileName = Path.GetFileName(path);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
string pathRoot = Path.GetPathRoot(path);
string directoryName = Path.GetDirectoryName(path);
string fullPath = Path.GetFullPath(path);

As you can see, you can easily use the static method of the Path class to get file extension, file name, path root, directory name or full path...etc