Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Meaning of Slash Character

The slash character (/), depending on its position, has different meanings within a file URL.

  • The // after the file: is part of the general syntax of URLs. (The double slash // should always appear in a file URL according to the specification, but in practice many Web browsers allow it to be omitted).

  • The single slash between host and path is part of the syntax of URLs.

  • The slashes in path separate directory names in a hierarchical system of directories and subdirectories. In this usage, the slash is a general, system-independent way of separating the parts, and in a particular host system it might be used as such in any pathname (as in Unix systems).

...

Panel
file://localhost/etc/fstab
file:///etc/fstab

 

 

 

 

 

 

Windows

Here are some examples which may be accepted by some applications on Windows systems, referring to the same, local file c:\WINDOWS\clock.avi

 

Panel
file://localhost/c|/WINDOWS/clock.avi
file:///c|/WINDOWS/clock.avi
file://localhost/c:/WINDOWS/clock.avi

 

Here is the URI as understood by the Windows Shell API:

Panel
file:///c:/WINDOWS/clock.avi

 

On Microsoft Windows systems, the normal colon (:) after a device letter has sometimes been replaced by a vertical bar (|) in file URLs. This reflected the original URL syntax, which made the colon a reserved character in a path part.

Since Internet Explorer 4, file URIs have been standardised on Windows, and should follow the following scheme. This applies to all applications which use URLMON or SHLWAPI for parsing, fetching or binding to URIs. To convert a path to a URL, use UrlCreateFromPath, and to convert a URL to a path, use PathCreateFromUrl.

To access a file "the file.txt", the following might be used.

For a network location:

Panel
file://hostname/path/to/the%20file.txt

 

Or for a local file, the hostname is omitted, but the slash is not (note the third slash):

Panel
file:///c:/path/to/the%20file.txt

 

This is not the same as providing the string "localhost" or the dot "." in place of the hostname. The string "localhost" will attempt to access the file as \\localhost\c:\path\to\the file.txt, which will not work since the colon is not allowed in a share name. The dot "." results in the string being passed as \\.\c:\path\to\the file.txt, which will work for local files, but not shares on the local system. For example file://./sharename/path/to/the%20file.txt will not work, because it will result in sharename being interpreted as part of the DOSDEVICES namespace, not as a network share.

 

Info

Do not be mistaken that these entries mean the files were opened in the browser. Accessing local files on a Windows system will result in file entries being created.