Getting file names without extensions

You can use Path.GetFileNameWithoutExtension:

foreach (FileInfo fi in smFiles)
{
    builder.Append(Path.GetFileNameWithoutExtension(fi.Name));
    builder.Append(", ");
}

Although I am surprised there isn’t a way to get this directly from the FileInfo (or at least I can’t see it).

Leave a Comment