If you ever find yourself manually parsing a file name or any part of a path, stop! It's very tempting to use a couple of lines of code to trim an extension off of a file, but why do it. Also, if you ever have a directory path and a file name, don't concatenate the two strings together (making sure that a “/” is in between), us Path.Combine instead. I think that a lot of code can be reduced by reusing the BCL. Every now and then you might save 15 minutes by taking 5 minutes to research what is available in the BCL.
Let's take a look at the System.IO.Path class and see what it can do for us. Just by looking at the following method names, I'm sure you can figure out how to use them to reduce your codebase:
Public Fields
Public Methods
Posted
02-10-2005 12:36 PM
by
Jeffrey Palermo