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).
More Related Contents:
- How to get ALL child controls of a Windows Forms form of a specific type (Button/Textbox)?
- Calling the base constructor in C#
- Detect if deserialized object is missing a field with the JsonConvert class in Json.NET
- Calculate the execution time of a method
- Detect if running as Administrator with or without elevated privileges?
- What is the best way to check for Internet connectivity using .NET?
- Kill child process when parent process is killed
- LINQ to Entities does not recognize the method ‘Double Parse(System.String)’ method, and this method cannot be translated into a store expression
- Remove items from one list in another
- How do I invert a colour?
- WPF Application that only has a tray icon
- Can’t find System.Windows.Media namespace?
- How is GetHashCode() of C# string implemented?
- No console output when using AllocConsole and target architecture x86
- MD5 hash with salt for keeping password in DB in C#
- How to prevent blank xmlns attributes in output from .NET’s XmlDocument?
- In .NET/C# test if process has administrative privileges
- Record Video of Screen using .NET technologies [closed]
- Associate a private key with the X509Certificate2 class in .net
- How to programmatically discover mapped network drives on system and their server names?
- How do I get a list of installed updates and hotfixes?
- How to implement a singleton in C#?
- cannot implicitly convert type ‘bool?’ to ‘bool’. An explicit conversion exists (are you missing a cast?)
- Check if an executable exists in the Windows path
- What does “DisplayClass” name mean when calling lambda?
- What value should I pass into TimeZoneInfo.FindSystemTimeZoneById(String)?
- VS2010 – How to automatically stop compile on first compile error
- How to check if the system audio is muted?
- Is int? thread safe?
- How to empty/flush Windows READ disk cache in C#?