Moved to WordPress

After a frustrating experience with The BlogEngine.NET and no desire whatsoever to troubleshoot the problem beyond a few simple tests, I’ve switched my blog to using WordPress. I generally liked BlogEngine, but for some unknown reason, my current feed reader (Google Reader), kept reporting that old blog posts had changed when in fact they really had not. I know it wasn’t just me either having this problem, so I hope that this annoying issue does not repeat itself with WordPress.

I’ve got a few easy ways to subscribe to the new feed:

technorati add aol netvibes myyahoo modern freedictionary ngsub

Sorry about the inconvenience.

Now that I believe this problem is fixed, I’m going to start posting again more frequently. I avoided posting knowing that my feed was having issues.

SnugUp – a SmugMug Mass Uploader

I put the finishing touches on a web page for a new application I just finished, SnugUp. It’s only useful if you have a SmugMug account, which I’d highly recommend if you’re serious about photos. Sign up here.

It’s written using .NET 3.5 — all WPF (except for a file dialog … :) ).

You can find out more here:

image

I’ve used some elements of old posts to make it efficient to show thumbnails and some other tricks of WPF. Now that I’m done, I’ll see if there’s anything new and interesting that I’ve discovered.

iTunes, by dummies?

I downloaded a few videos over the weekend about the new iPhone SDK via iTunes. My iPod Classic isn’t set up to synchronize movies, so I need to adjust the settings so that the movies would be available on the iPod.

Here’s the warning dialog that was displayed when I clicked "Sync Movies":

image

All existing songs, movies and TV shows will be removed and replaced with movies from my iTunes library? What happens to the songs and TV shows? Huh?

I use Media Monkey to manage my iPod’s music collection as iTunes is TERRIBLE on Windows for managing music, playing music, searching music … pretty much everything it does is sub-par and odd. But, this?!

Does Apple secretly have a guidebook internally, "Apple Inhumane Interface Guideline for Developing Mediocre Windows Applications: A Simple Guide to Getting People to Hating Microsoft Windows More."

Unfortunately, Media Monkey isn’t able to manage movie/video files.

I’m not willing to click "Sync Movies" if it should wipe out all of the songs I have. It takes hours to copy them all back.

Converting a mapped drive letter to a network path using C#

Occasionally you might have the need to convert a mapped drive letter to a UNC or network path. For example, a drive letter such as  “Z” might be mapped to a network share:

image

In this example, the “Z” drive is mapped to a “Personal” folder on a server named “Home”.

If you want to store for example a UNC path to a file rather than a drive letter, you’ll need to convert the “Z” drive to the corresponding UNC root path. Here’s the C# code I wrote to do this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace WiredPrairie.Samples
{
    public static class Pathing
    {
        [DllImport("mpr.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern int WNetGetConnection(
            [MarshalAs(UnmanagedType.LPTStr)] string localName, 
            [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, 
            ref int length);
        /// <summary>
        /// Given a path, returns the UNC path or the original. (No exceptions
        /// are raised by this function directly). For example, "P:\2008-02-29"
        /// might return: "\\networkserver\Shares\Photos\2008-02-09"
        /// </summary>
        /// <param name="originalPath">The path to convert to a UNC Path</param>
        /// <returns>A UNC path. If a network drive letter is specified, the
        /// drive letter is converted to a UNC or network path. If the 
        /// originalPath cannot be converted, it is returned unchanged.</returns>
        public static string GetUNCPath(string originalPath)
        {
            StringBuilder sb = new StringBuilder(512);
            int size = sb.Capacity;

            // look for the {LETTER}: combination ...
            if (originalPath.Length > 2 && originalPath[1] == ':')
            {
                // don't use char.IsLetter here - as that can be misleading
                // the only valid drive letters are a-z && A-Z.
                char c = originalPath[0];
                if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
                {
                    int error = WNetGetConnection(originalPath.Substring(0, 2), 
                        sb, ref size);
                    if (error == 0)
                    {                        
                        DirectoryInfo dir = new DirectoryInfo(originalPath);

                        string path = Path.GetFullPath(originalPath)
                            .Substring(Path.GetPathRoot(originalPath).Length);
                        return Path.Combine(sb.ToString().TrimEnd(), path);
                    }
                }
            }
            
            return originalPath;
        }
    }
}

All of the magic takes place in a Windows API function call, WNetGetConnection.

I’m using this function so that I can verify that given two file names, I can be assured that they are pointing to the same physical location. (Is “Z:\Backups\Backup1.zip” the same as “\\home\Personal\Backups\Backup1.zip”).