c# fileinfo get name without extension code example
Example 1: c# get file extension
string myFilePath = @"C:\MyFile.txt";
string ext = Path.GetExtension(myFilePath);
// ext would be ".txt"
Example 2: c# fileinfo filename without extension
DirectoryInfo dir = new DirectoryInfo(path);
FileInfo[] files = dir.GetFiles("*.txt");
foreach (FileInfo file in files)
{
string noExtension = Path.GetFileNameWithoutExtension(file.Name);
}