Running A Little Behind

So things were a little hectic over the last week. Amanda and I were really busy going to the Sammy Hagar concert on Tuesday and then Detroit over the weekend. My hope is to actually write posts over the next couple days about those very interesting topics. I have been debating setting their dates to the date that they happened so it’s a little more historically accurate. 🙂

Change a File’s Extension in C#

This is a quick post about how to change the extension in a path. Note: This does NOT change the extension of the file. It will have to be moved for that to happen.

[code lang=”c#”]
func
System.IO.Path.GetDirectoryName(strFile) + System.IO.Path.DirectorySeparatorChar + System.IO.Path.GetFileNameWithoutExtension(strFile) + “.txt”;
[/code]

How to Find A File’s Extension in C#

Every time I think I’m going to need to write some quick function to do some simple task in a .NET application I shocked to find that the function already exists. Case in point. Today I needed to find the extension of a file and it turns out all you need to do is call this function:

[code language=”c#”]
System.IO.Path.GetExtension(Filename)
[/code]

Enough said.