Absolute and Relative Paths

Files and directories can be uniquely identified using their path names. Path  names specify where files and directories are located. When specifying path  names, you can either use an absolute or relative path.

An absolute path is the complete path name of a file or a directory. It  starts with the root directory up to the parent directory where another  directory of the file is contained. An example of an absolute path is C:\Program Files\Tutorials\Sample.txt. In  case of websites, an example of an absolute path specifies the domain name such  as sample.html.
Relative path doesn’t require you to specify the root directory. You can simply  specify a name of another directory or file to search for it on the same  directory where the program that calls it resides. For example, if you are in  the C:\ directory and you specify “Sample.txt” as  a relative path, then you are actually calling C:\Sample.txt.  If for example you give “Program Files/Sample.txt”  while the program calling it is in the C:\  directory, then you will be calling C:\.

In the following lessons, we will be using string verbatims when specifying a  path. This is to avoid using double backslash which could make our paths less  natural to look at. For example, for specifying C:\Program Files\Tutorials\Sample.txt, the string should look like  this:

@"C:\Program Files\Tutorials\Sample.txt"

If string verbatim is not used, it should look like this:

"C:\\Program Files\\Tutorials\\Sample.txt"

The next lessons discuss the different classes of the System.IO namespace  that can be used to create, delete, copy, and move files and directories and  many more.