Search code examples
filesystemspathname

Difference between forward and backslash


What is the difference in using a forward slash and backslash in navigating file systems. Also what is the difference between ./ and ../?


Solution

  • Well, in most languages backslashes need to be escaped in string literals, slashes do not. Further backslashes only work on Windows, while slashes work pretty much everywhere.

    On the other hand, when passing path names as arguments to Windows programs, using slashes might not work because many Windows programs use slashes to signify command line flags, so you need to use backslashes.

    On . vs. ..: . is the current directory, .. is the parent directory.