These days I was asking myself how to get the file name without the extension. I confess I was tempted to use a regex to solve this problem :)
But no worries. There is a method in System.IO.Path
specific for this situation.
using System.IO; /// /// Get file name without extension /// static string GetFileName(string path) { return Path.GetFileNameWithoutExtension(path); } /// /// Get file name without extension /// static string GetFileName(FileInfo fileInfo) { return Path.GetFileNameWithoutExtension(fileInfo.Name); }
Credits go for this answer in StackOverflow forum.
Top comments (0)