So what IS the right direction of the path’s slash (/ or \) under Windows?

Windows is the bastard child of operating systems in this regard, but a lot of APIs will accept forward slashes as well. On Windows, a file path looks like this:

C:\Users\jsmith\Documents\file.txt

On a Unix-like system (including Mac OS X and Linux), the same path would look like this:

/home/jsmith/Documents/file.txt

A URL, standardized in RFC 1738, always uses forward slashes, regardless of platform:

http://home.example.com/Documents/file.txt

The reason for this is historical. Not even Windows can reverse our thinking on URLs. When you’re talking about backslashes, the only platform you’ll find that uses them is Windows (and some other novelty ones).

Where you might see backslashes used other than Windows would be UNC paths — however, Windows is the chief proponent of these as well:

\\HOMESVR\Documents\file.txt

And whatever you do, don’t make a commercial for your Web site and say “my company dot com back slash promotion”.

Leave a Comment