Tuesday, February 19, 2008

I was just setting at a command prompt in Vista on my laptop and I typed 'cd /' out of habit and, to my surprise, it worked! Not only that, but tab completion still behaved as expected!

I actually have been using the '/' character in PowerShell because it is easier to type than '\' (not as far to reach) and it is the default in *NIX systems as well (i.e. my Ubuntu installation).

Now granted, I probably shouldn't get used to this in the event that I inadvertently code a '/' character in one of my programs, but then again, I should technically be using the System.IO.Path.PathSeparator anyway.

I get excited about the little things.

NOTE - this might be the result of Service Pack 1 on Vista also...

UPDATE - I lied. You can type 'cd /' and get to the root, but tab completion still completes only for the current directory. In other words, if you're current directory is c:\windows\ and you type 'cd /[tab]', you'll get directories that are in c:\windows. Sorry. My excitement just dropped a little.

posted on Tuesday, February 19, 2008 5:30:08 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Monday, February 11, 2008

Last week, a small group of us traveled up to hear Jean-Paul Boodhoo present to the Northwest Arkansas .NET User Group. JP presented on advanced uses of generics in .NET (i.e. more than just strongly typed collections) though we also had a great look at Test Driven Development as well as some of the new features in C# 3.0.

The presentation was great and it got me really excited about user groups in general, which is why I'm also excited to announce that Fort Smith will be getting its own user group! Many thanks to Michael Paladino for doing a lot of the work in getting this started. FSDNUG went live last week. I'm hoping to add a feed to the site at some point so that news can easily be pushed out without continually checking the site, but for now, it is just static HTML.

Raymond Lewallen will be kicking off the group with a presentation on Behavior Driven Development. I've read about BDD and am attempting to practice TDD, so I'm excited to hear Raymond's talk. If you live in the area, be sure to come out for the meeting!

posted on Monday, February 11, 2008 12:43:38 PM (Central Standard Time, UTC-06:00)  #    Comments [4]
 Tuesday, February 05, 2008

I've found myself wishing that I could pass in more than two arguments to Path.Combine. That is, something like this:

Path.Combine(rootPath, someCalculatedPath, someKnownFileName);

As it is, Path.Combine only accepts two arguments, so I end up with calls that look like this:

Path.Combine(Path.Combine(rootPath, comeCalculatedPath), someKnownFileName);

It seems like a hassle to me. Here is a simple wrapper function (with accompanying test) that will accomplish this:

public static class FileUtils
{
    public static string CombinePaths(params string[] paths)
    {
        if (paths.Length == 0) return string.Empty; 

        return Path.Combine(paths.First(), CombinePaths(paths.Skip(1).ToArray()));
    }
} 

[TestFixture]
public class FileUtilsTests
{
    [Test]
    public void Should_combine_paths_correctly()
    {
        string expected = @"c:\some\path\to\file.txt"; 

        Assert.AreEqual(expected, FileUtils.CombinePaths("c:\\some", "path\\to", "file.txt"));
    }
}
posted on Tuesday, February 05, 2008 7:29:02 AM (Central Standard Time, UTC-06:00)  #    Comments [2]