Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

It seems Windows insists on writing a backslash \ in file paths, whereas .NET's URI class writes them with a slash /. Is there any right way, that is accepted even in the most primitive systems? And why is .NET's URI showing the other slash compared with the rest of Windows?

like image 413
Letterman Avatar asked Oct 19 '09 17:10

Letterman


People also ask

Does Windows use forward slash or backslash?

Windows uses backslashes for paths, while everything else seems to use forward slashes. Modern software tries to automatically correct you when you type the wrong type of slash, so it doesn't matter which type of slash you use most of the time.

Which way should the slash go?

The forward slash is the type you're most likely to see or use in writing. Forward (/) slashes serve many purposes in writing. They are commonly used to separate words, lines of poetry, abbreviations, dates, and fractions. Backslashes (\) are primarily used in computer coding.

Where does the forward slash and backslash go?

The backslash is used only for computer coding. The forward slash, often simply referred to as a slash, is a punctuation mark used in English. The only time it is appropriate to use a comma after a slash is when demonstrating breaks between lines of poetry, songs, or plays.

How do you use backslash on Windows?

Creating the \ symbol on a U.S. keyboard On English PC and Mac keyboards, the backslash key is also the pipe key. It is located above the Enter key (Return key), and below the Backspace key. Pressing \ key creates a backslash.


1 Answers

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".

like image 142
Jed Smith Avatar answered Oct 28 '22 00:10

Jed Smith