##### Page tree
Go to start of banner

# Introduction

The file URI scheme specified in RFC 1630 and RFC 1738, and is typically used to retrieve files from the host computer.  Figure 1 below shows NetAnalysis with a number of file entries filtered, as stored by Microsoft Internet Explorer v9 in its history INDEX.DAT files.

These entries are created (along with Microsoft Windows Shortcut entries) by accessing files on the computer system which typically have an HKEY_CLASSES_ROOT entry in the registry to inform Explorer how the file should be dealt with.

Figure 1

# 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).

## Examples

### Unix

Here are two Unix examples pointing to the same /etc/fstab file:

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

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:

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:

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):

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.

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.