How to find the extension of a file in C#? October 24, 2022 by Tarik Path.GetExtension string myFilePath = @"C:\MyFile.txt"; string ext = Path.GetExtension(myFilePath); // ext would be ".txt"