File Referencing

Refer to the example of the library. To locate a book dealing with biology, you would have to go to the fourth room on the third floor. Similarly, in the case of the directory structure shown in Figure 1.4, to access the PERSONAL files, you would have to go to the subdirectory PERSONAL under the directory EXPENSES.

DOS allows the user to access files by moving from one directory to another. To begin with, the user is always located in the root directory.

While moving from one directory to another, certain rules have to be followed. Let us take an example.

You cannot go directly from the LETTERS directory to the EXPENSES directory. To go from LETTERS to EXPENSES, you will have to go to the root directory first and then proceed to EXPENSES. Similarly, to go from PERSONAL to OFFICIAL, you would first have to go to the parent directory EXPENSES and then proceed to OFFICIAL. In other words, when moving from one directory to another, you first have to go to the parent directory. However, you can go directly to the root directory from any subdirectory.

Besides the method of moving to different directories to access files, there is another method that ensures file access by defining a path to DOS.

Let us first understand the mechanism of path. Refer to the example of the library. If you do not want to go and get a book yourself, you ask a friend to do so and give him or her the required directions.

Similarly, you can provide DOS with a path to the target directory.

Suppose you wish to access a file from the PERSONAL directory. You would have to first refer to the root directory and then the EXPENSES directory.

To access a file called TRAVEL.EXP is the PERSONAL directory, you would have to specify the path as:

Path Referencing

Path Referencing


1 is the drive name.

2 is the root directory.

3 is the directory under the root directory, starting from which a file has to be accessed.

4 is the subdirectory under the directory mentioned in 3 (3 is the parent directory).

5 is the primary name of the fiJe to be accessed.

6 is the extension name of the file to be accessed.

This is the complete file reference that indicates that there is a subdirectory PERSONAL under a directory EXPENSES which is under the root directory, and the subdirectory PERSONAL contains a file named TRAVEL.EXP.

The '/' (backslash) is a convention that must be followed to enable DOS to trace the path. By specifying the first '/', DOS is automatically directed to go to the root directory from any directory. Thus, any path that is stated essentially starts from the root. The subsequent backslashes are to separate the various directories, subdirectories, and the file name that has been specified in the path.