Given a filesystem path, is there a shorter way to extract the filename without its extension?

Solution 1:

Path.GetFileName

Returns the file name and extension of a file path that is represented by a read-only character span.


Path.GetFileNameWithoutExtension

Returns the file name without the extension of a file path that is represented by a read-only character span.


The Path class is wonderful.

Solution 2:

try

fileName = Path.GetFileName (path);

http://msdn.microsoft.com/de-de/library/system.io.path.getfilename.aspx