Working with file paths in .NET

EmailFacebookGoogle+LinkedInTwitterShare

Since I do a lot of file manipulations in my custom routines, my programming snippets library is full of little string manipulator functions written for the use of manipulating strings containing file paths.

Today I ran across the “Path” class in the System.IO namespace. Where has this been all my life?! (Well since the 1.1 .Net framework.) Check out this class! GetFileNameWithoutExtension, GetExtension, GetPathRoot, GetDirectoryName, ChangeExtension, etc.

If I had all the time back that I have spent writing my own versions of these methods I’d be 12 years old.