Return to site

The Path Download

broken image
Download
-->

Members of many of the types in the System.IO namespace include a path parameter that lets you specify an absolute or relative path to a file system resource. This path is then passed to Windows file system APIs. This topic discusses the formats for file paths that you can use on Windows systems.

The Path of Hercules Features. Over 60 interesting and unique levels; 7 legendary cities to explore; Challenging Match 3 puzzles and hidden object gameplay; The Path of Hercules is a free full version game to download and play. My Personal Mission is to recognize, promote, and inspire divine connection in myself and others. I live my mission by writing, speaking, coaching, and creating opportunities for you to get clear about who you are, what you were created to do, and how to live, lead, and love those you have been called to.

I'm trying to set the Downloads folder as the Initial Directory for an OpenFileDialog. However, as explained here, the GetFolderPath function that I would normally use doesn't provide a enum for the Downloads folder: OpenFileDialogBrowse.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder. The Path of the Masters Item Preview remove-circle Share or Embed This Item. DOWNLOAD OPTIONS download 1 file. ABBYY GZ download. Download 1 file. Free Ordnance Survey Mapping side by side with Google Aerial Imagery for UK Outdoor Pursuits.

Traditional DOS paths

A standard DOS path can consist of three components:

  • A volume or drive letter followed by the volume separator (:).
  • A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
  • An optional filename. The directory separator character separates the file path and the filename.

If all three components are present, the path is absolute. If no volume or drive letter is specified and the directory name begins with the directory separator character, the path is relative from the root of the current drive. Otherwise, the path is relative to the current directory. The following table shows some possible directory and file paths.

PathDescription
C:DocumentsNewslettersSummer2018.pdfAn absolute file path from the root of drive C:.
Program FilesCustom UtilitiesStringFinder.exeAn absolute path from the root of the current drive.
2018January.xlsxA relative path to a file in a subdirectory of the current directory.
..PublicationsTravelBrochure.pdfA relative path to file in a directory that is a peer of the current directory.
C:Projectsapilibraryapilibrary.slnAn absolute path to a file from the root of drive C:.
C:Projectsapilibraryapilibrary.slnA relative path from the current directory of the C: drive.

Important

Note the difference between the last two paths. Both specify the optional volume specifier (C: in both cases), but the first begins with the root of the specified volume, whereas the second does not. As result, the first is an absolute path from the root directory of drive C:, whereas the second is a relative path from the current directory of drive C:. Use of the second form when the first is intended is a common source of bugs that involve Windows file paths.

You can determine whether a file path is fully qualified (that is, it the path is independent of the current directory and does not change when the current directory changes) by calling the Path.IsPathFullyQualified method. Note that such a path can include relative directory segments (. and ..) and still be fully qualified if the resolved path always points to the same location.

The following example illustrates the difference between absolute and relative paths. It assumes that the directory D:FY2018 exists, and that you haven't set any current directory for D: from the command prompt before running the example.

If you would like to see code comments translated to languages other than English, let us know in this GitHub discussion issue.

UNC paths

Universal naming convention (UNC) paths, which are used to access network resources, have the following format:

  • A server or host name, which is prefaced by . The server name can be a NetBIOS machine name or an IP/FQDN address (IPv4 as well as v6 are supported).
  • A share name, which is separated from the host name by . Together, the server and share name make up the volume.
  • A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
  • An optional filename. The directory separator character separates the file path and the filename.

The following are some examples of UNC paths:

PathDescription
system07C$The root directory of the C: drive on system07.
Server2ShareTestFoo.txtThe Foo.txt file in the Test directory of the Server2Share volume.

UNC paths must always be fully qualified. They can include relative directory segments (. and ..), but these must be part of a fully qualified path. You can use relative paths only by mapping a UNC path to a drive letter.

DOS device paths

The Windows operating system has a unified object model that points to all resources, including files. These object paths are accessible from the console window and are exposed to the Win32 layer through a special folder of symbolic links that legacy DOS and UNC paths are mapped to. This special folder is accessed via the DOS device path syntax, which is one of:

.C:TestFoo.txt?C:TestFoo.txt

In addition to identifying a drive by its drive letter, you can identify a volume by using its volume GUID. This takes the form:

.Volume{b75e2c83-0000-0000-0000-602f00000000}TestFoo.txt?Volume{b75e2c83-0000-0000-0000-602f00000000}TestFoo.txt

Note

DOS device path syntax is supported on .NET implementations running on Windows starting with .NET Core 1.1 and .NET Framework 4.6.2.

The DOS device path consists of the following components:

  • The device path specifier (. or ?), which identifies the path as a DOS device path.

    Note

    The ? is supported in all versions of .NET Core and .NET 5+ and in .NET Framework starting with version 4.6.2.

  • A symbolic link to the 'real' device object (C: in the case of a drive name, or Volume{b75e2c83-0000-0000-0000-602f00000000} in the case of a volume GUID).

    The first segment of the DOS device path after the device path specifier identifies the volume or drive. (For example, ?C: and .BootPartition.)

    There is a specific link for UNCs that is called, not surprisingly, UNC. For example:

    .UNCServerShareTestFoo.txt?UNCServerShareTestFoo.txt

    For device UNCs, the server/share portion forms the volume. For example, in ?server1e:utilitiesfilecomparer, the server/share portion is server1utilities. This is significant when calling a method such as Path.GetFullPath(String, String) with relative directory segments; it is never possible to navigate past the volume.

DOS device paths are fully qualified by definition. Relative directory segments (. and ..) are not allowed. Current directories never enter into their usage.

Example: Ways to refer to the same file

The following example illustrates some of the ways in which you can refer to a file when using the APIs in the System.IO namespace. The example instantiates a FileInfo object and uses its Name and Length properties to display the filename and the length of the file.

Path normalization

Almost all paths passed to Windows APIs are normalized. During normalization, Windows performs the following steps:

  • Identifies the path.
  • Applies the current directory to partially qualified (relative) paths.
  • Canonicalizes component and directory separators.
  • Evaluates relative directory components (. for the current directory and .. for the parent directory).
  • Trims certain characters.

This normalization happens implicitly, but you can do it explicitly by calling the Path.GetFullPath method, which wraps a call to the GetFullPathName() function. You can also call the Windows GetFullPathName() function directly using P/Invoke.

Identify the path

The first step in path normalization is identifying the type of path. Paths fall into one of a few categories:

  • They are device paths; that is, they begin with two separators and a question mark or period (? or .).
  • They are UNC paths; that is, they begin with two separators without a question mark or period.
  • They are fully qualified DOS paths; that is, they begin with a drive letter, a volume separator, and a component separator (C:).
  • They designate a legacy device (CON, LPT1).
  • They are relative to the root of the current drive; that is, they begin with a single component separator ().
  • They are relative to the current directory of a specified drive; that is, they begin with a drive letter, a volume separator, and no component separator (C:).
  • They are relative to the current directory; that is, they begin with anything else (temptestfile.txt).

The type of the path determines whether or not a current directory is applied in some way. It also determines what the 'root' of the path is.

Handle legacy devices

If the path is a legacy DOS device such as CON, COM1, or LPT1, it is converted into a device path by prepending . and returned.

A path that begins with a legacy device name is always interpreted as a legacy device by the Path.GetFullPath(String) method. For example, the DOS device path for CON.TXT is .CON, and the DOS device path for COM1.TXTfile1.txt is .COM1.

Apply the current directory

If a path isn't fully qualified, Windows applies the current directory to it. UNCs and device paths do not have the current directory applied. Neither does a full drive with separator C:.

If the path starts with a single component separator, the drive from the current directory is applied. For example, if the file path is utilities and the current directory is C:temp, normalization produces C:utilities.

If the path starts with a drive letter, volume separator, and no component separator, the last current directory set from the command shell for the specified drive is applied. If the last current directory was not set, the drive alone is applied. For example, if the file path is D:sources, the current directory is C:Documents, and the last current directory on drive D: was D:sources, the result is D:sourcessources. These 'drive relative' paths are a common source of program and script logic errors. Assuming that a path beginning with a letter and a colon isn't relative is obviously not correct.

If the path starts with something other than a separator, the current drive and current directory are applied. For example, if the path is filecompare and the current directory is C:utilities, the result is C:utilitiesfilecompare.

Important

Relative paths are dangerous in multithreaded applications (that is, most applications) because the current directory is a per-process setting. Any thread can change the current directory at any time. Starting with .NET Core 2.1, you can call the Path.GetFullPath(String, String) method to get an absolute path from a relative path and the base path (the current directory) that you want to resolve it against.

Canonicalize separators

All forward slashes (/) are converted into the standard Windows separator, the back slash (). If they are present, a series of slashes that follow the first two slashes are collapsed into a single slash.

Evaluate relative components

As the path is processed, any components or segments that are composed of a single or a double period (. or ..) are evaluated:

  • For a single period, the current segment is removed, since it refers to the current directory.

  • For a double period, the current segment and the parent segment are removed, since the double period refers to the parent directory.

    Parent directories are only removed if they aren't past the root of the path. The root of the path depends on the type of path. It is the drive (C:) for DOS paths, the server/share for UNCs (ServerShare), and the device path prefix for device paths (? or .).

Trim characters

Along with the runs of separators and relative segments removed earlier, some additional characters are removed during normalization:

  • If a segment ends in a single period, that period is removed. (A segment of a single or double period is normalized in the previous step. A segment of three or more periods is not normalized and is actually a valid file/directory name.)

  • If the path doesn't end in a separator, all trailing periods and spaces (U+0020) are removed. If the last segment is simply a single or double period, it falls under the relative components rule above.

    This rule means that you can create a directory name with a trailing space by adding a trailing separator after the space.

    Important

    You should never create a directory or filename with a trailing space. Trailing spaces can make it difficult or impossible to access a directory, and applications commonly fail when attempting to handle directories or files whose names include trailing spaces.

Skip normalization

Normally, any path passed to a Windows API is (effectively) passed to the GetFullPathName function and normalized. There is one important exception: a device path that begins with a question mark instead of a period. Unless the path starts exactly with ? (note the use of the canonical backslash), it is normalized.

Why would you want to skip normalization? There are three major reasons:

  1. To get access to paths that are normally unavailable but are legal. A file or directory called hidden., for example, is impossible to access in any other way.

  2. To improve performance by skipping normalization if you've already normalized.

  3. On .NET Framework only, to skip the MAX_PATH check for path length to allow for paths that are greater than 259 characters. Most APIs allow this, with some exceptions.

Note

The

.NET Core and .NET 5+ handles long paths implicitly and does not perform a MAX_PATH check. The MAX_PATH check applies only to .NET Framework.

Skipping normalization and max path checks is the only difference between the two device path syntaxes; they are otherwise identical. Be careful with skipping normalization, since you can easily create paths that are difficult for 'normal' applications to deal with.

Paths that start with ? are still normalized if you explicitly pass them to the GetFullPathName function.

You can pass paths of more than MAX_PATH characters to GetFullPathName without ?. It supports arbitrary length paths up to the maximum string size that Windows can handle.

Case and the Windows file system

A peculiarity of the Windows file system that non-Windows users and developers find confusing is that path and directory names are case-insensitive. That is, directory and file names reflect the casing of the strings used when they are created. For example, the method call

creates a directory named TeStDiReCtOrY. If you rename a directory or file to change its case, the directory or file name reflects the case of the string used when you rename it. For example, the following code renames a file named test.txt to Test.txt:

However, directory and file name comparisons are case-insensitive. If you search for a file named 'test.txt', .NET file system APIs ignore case in the comparison. 'Test.txt', 'TEST.TXT', 'test.TXT', and any other combination of uppercase and lowercase letters will match 'test.txt'.

Setting the path and environment variables will differ depending on the version of Windows you have on your computer. Choose a link below for your version of Windows.

Note

Administrator privileges are usually required to modify the path and environment variables.

Setting the path and variables in Windows 10

  1. From the desktop, right-click the very bottom-left corner of the screen to get the Power User Task Menu.
  2. From the Power User Task Menu, click System.
  3. In the Settings window, scroll down to the Related settings section and click the System info link.
  4. In the System window, click the Advanced system settings link in the left navigation pane.
  5. In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
  6. In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
Note

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.

The Path Download
-->

Members of many of the types in the System.IO namespace include a path parameter that lets you specify an absolute or relative path to a file system resource. This path is then passed to Windows file system APIs. This topic discusses the formats for file paths that you can use on Windows systems.

The Path of Hercules Features. Over 60 interesting and unique levels; 7 legendary cities to explore; Challenging Match 3 puzzles and hidden object gameplay; The Path of Hercules is a free full version game to download and play. My Personal Mission is to recognize, promote, and inspire divine connection in myself and others. I live my mission by writing, speaking, coaching, and creating opportunities for you to get clear about who you are, what you were created to do, and how to live, lead, and love those you have been called to.

I'm trying to set the Downloads folder as the Initial Directory for an OpenFileDialog. However, as explained here, the GetFolderPath function that I would normally use doesn't provide a enum for the Downloads folder: OpenFileDialogBrowse.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder. The Path of the Masters Item Preview remove-circle Share or Embed This Item. DOWNLOAD OPTIONS download 1 file. ABBYY GZ download. Download 1 file. Free Ordnance Survey Mapping side by side with Google Aerial Imagery for UK Outdoor Pursuits.

Traditional DOS paths

A standard DOS path can consist of three components:

  • A volume or drive letter followed by the volume separator (:).
  • A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
  • An optional filename. The directory separator character separates the file path and the filename.

If all three components are present, the path is absolute. If no volume or drive letter is specified and the directory name begins with the directory separator character, the path is relative from the root of the current drive. Otherwise, the path is relative to the current directory. The following table shows some possible directory and file paths.

PathDescription
C:DocumentsNewslettersSummer2018.pdfAn absolute file path from the root of drive C:.
Program FilesCustom UtilitiesStringFinder.exeAn absolute path from the root of the current drive.
2018January.xlsxA relative path to a file in a subdirectory of the current directory.
..PublicationsTravelBrochure.pdfA relative path to file in a directory that is a peer of the current directory.
C:Projectsapilibraryapilibrary.slnAn absolute path to a file from the root of drive C:.
C:Projectsapilibraryapilibrary.slnA relative path from the current directory of the C: drive.

Important

Note the difference between the last two paths. Both specify the optional volume specifier (C: in both cases), but the first begins with the root of the specified volume, whereas the second does not. As result, the first is an absolute path from the root directory of drive C:, whereas the second is a relative path from the current directory of drive C:. Use of the second form when the first is intended is a common source of bugs that involve Windows file paths.

You can determine whether a file path is fully qualified (that is, it the path is independent of the current directory and does not change when the current directory changes) by calling the Path.IsPathFullyQualified method. Note that such a path can include relative directory segments (. and ..) and still be fully qualified if the resolved path always points to the same location.

The following example illustrates the difference between absolute and relative paths. It assumes that the directory D:FY2018 exists, and that you haven't set any current directory for D: from the command prompt before running the example.

If you would like to see code comments translated to languages other than English, let us know in this GitHub discussion issue.

UNC paths

Universal naming convention (UNC) paths, which are used to access network resources, have the following format:

  • A server or host name, which is prefaced by . The server name can be a NetBIOS machine name or an IP/FQDN address (IPv4 as well as v6 are supported).
  • A share name, which is separated from the host name by . Together, the server and share name make up the volume.
  • A directory name. The directory separator character separates subdirectories within the nested directory hierarchy.
  • An optional filename. The directory separator character separates the file path and the filename.

The following are some examples of UNC paths:

PathDescription
system07C$The root directory of the C: drive on system07.
Server2ShareTestFoo.txtThe Foo.txt file in the Test directory of the Server2Share volume.

UNC paths must always be fully qualified. They can include relative directory segments (. and ..), but these must be part of a fully qualified path. You can use relative paths only by mapping a UNC path to a drive letter.

DOS device paths

The Windows operating system has a unified object model that points to all resources, including files. These object paths are accessible from the console window and are exposed to the Win32 layer through a special folder of symbolic links that legacy DOS and UNC paths are mapped to. This special folder is accessed via the DOS device path syntax, which is one of:

.C:TestFoo.txt?C:TestFoo.txt

In addition to identifying a drive by its drive letter, you can identify a volume by using its volume GUID. This takes the form:

.Volume{b75e2c83-0000-0000-0000-602f00000000}TestFoo.txt?Volume{b75e2c83-0000-0000-0000-602f00000000}TestFoo.txt

Note

DOS device path syntax is supported on .NET implementations running on Windows starting with .NET Core 1.1 and .NET Framework 4.6.2.

The DOS device path consists of the following components:

  • The device path specifier (. or ?), which identifies the path as a DOS device path.

    Note

    The ? is supported in all versions of .NET Core and .NET 5+ and in .NET Framework starting with version 4.6.2.

  • A symbolic link to the 'real' device object (C: in the case of a drive name, or Volume{b75e2c83-0000-0000-0000-602f00000000} in the case of a volume GUID).

    The first segment of the DOS device path after the device path specifier identifies the volume or drive. (For example, ?C: and .BootPartition.)

    There is a specific link for UNCs that is called, not surprisingly, UNC. For example:

    .UNCServerShareTestFoo.txt?UNCServerShareTestFoo.txt

    For device UNCs, the server/share portion forms the volume. For example, in ?server1e:utilitiesfilecomparer, the server/share portion is server1utilities. This is significant when calling a method such as Path.GetFullPath(String, String) with relative directory segments; it is never possible to navigate past the volume.

DOS device paths are fully qualified by definition. Relative directory segments (. and ..) are not allowed. Current directories never enter into their usage.

Example: Ways to refer to the same file

The following example illustrates some of the ways in which you can refer to a file when using the APIs in the System.IO namespace. The example instantiates a FileInfo object and uses its Name and Length properties to display the filename and the length of the file.

Path normalization

Almost all paths passed to Windows APIs are normalized. During normalization, Windows performs the following steps:

  • Identifies the path.
  • Applies the current directory to partially qualified (relative) paths.
  • Canonicalizes component and directory separators.
  • Evaluates relative directory components (. for the current directory and .. for the parent directory).
  • Trims certain characters.

This normalization happens implicitly, but you can do it explicitly by calling the Path.GetFullPath method, which wraps a call to the GetFullPathName() function. You can also call the Windows GetFullPathName() function directly using P/Invoke.

Identify the path

The first step in path normalization is identifying the type of path. Paths fall into one of a few categories:

  • They are device paths; that is, they begin with two separators and a question mark or period (? or .).
  • They are UNC paths; that is, they begin with two separators without a question mark or period.
  • They are fully qualified DOS paths; that is, they begin with a drive letter, a volume separator, and a component separator (C:).
  • They designate a legacy device (CON, LPT1).
  • They are relative to the root of the current drive; that is, they begin with a single component separator ().
  • They are relative to the current directory of a specified drive; that is, they begin with a drive letter, a volume separator, and no component separator (C:).
  • They are relative to the current directory; that is, they begin with anything else (temptestfile.txt).

The type of the path determines whether or not a current directory is applied in some way. It also determines what the 'root' of the path is.

Handle legacy devices

If the path is a legacy DOS device such as CON, COM1, or LPT1, it is converted into a device path by prepending . and returned.

A path that begins with a legacy device name is always interpreted as a legacy device by the Path.GetFullPath(String) method. For example, the DOS device path for CON.TXT is .CON, and the DOS device path for COM1.TXTfile1.txt is .COM1.

Apply the current directory

If a path isn't fully qualified, Windows applies the current directory to it. UNCs and device paths do not have the current directory applied. Neither does a full drive with separator C:.

If the path starts with a single component separator, the drive from the current directory is applied. For example, if the file path is utilities and the current directory is C:temp, normalization produces C:utilities.

If the path starts with a drive letter, volume separator, and no component separator, the last current directory set from the command shell for the specified drive is applied. If the last current directory was not set, the drive alone is applied. For example, if the file path is D:sources, the current directory is C:Documents, and the last current directory on drive D: was D:sources, the result is D:sourcessources. These 'drive relative' paths are a common source of program and script logic errors. Assuming that a path beginning with a letter and a colon isn't relative is obviously not correct.

If the path starts with something other than a separator, the current drive and current directory are applied. For example, if the path is filecompare and the current directory is C:utilities, the result is C:utilitiesfilecompare.

Important

Relative paths are dangerous in multithreaded applications (that is, most applications) because the current directory is a per-process setting. Any thread can change the current directory at any time. Starting with .NET Core 2.1, you can call the Path.GetFullPath(String, String) method to get an absolute path from a relative path and the base path (the current directory) that you want to resolve it against.

Canonicalize separators

All forward slashes (/) are converted into the standard Windows separator, the back slash (). If they are present, a series of slashes that follow the first two slashes are collapsed into a single slash.

Evaluate relative components

As the path is processed, any components or segments that are composed of a single or a double period (. or ..) are evaluated:

  • For a single period, the current segment is removed, since it refers to the current directory.

  • For a double period, the current segment and the parent segment are removed, since the double period refers to the parent directory.

    Parent directories are only removed if they aren't past the root of the path. The root of the path depends on the type of path. It is the drive (C:) for DOS paths, the server/share for UNCs (ServerShare), and the device path prefix for device paths (? or .).

Trim characters

Along with the runs of separators and relative segments removed earlier, some additional characters are removed during normalization:

  • If a segment ends in a single period, that period is removed. (A segment of a single or double period is normalized in the previous step. A segment of three or more periods is not normalized and is actually a valid file/directory name.)

  • If the path doesn't end in a separator, all trailing periods and spaces (U+0020) are removed. If the last segment is simply a single or double period, it falls under the relative components rule above.

    This rule means that you can create a directory name with a trailing space by adding a trailing separator after the space.

    Important

    You should never create a directory or filename with a trailing space. Trailing spaces can make it difficult or impossible to access a directory, and applications commonly fail when attempting to handle directories or files whose names include trailing spaces.

Skip normalization

Normally, any path passed to a Windows API is (effectively) passed to the GetFullPathName function and normalized. There is one important exception: a device path that begins with a question mark instead of a period. Unless the path starts exactly with ? (note the use of the canonical backslash), it is normalized.

Why would you want to skip normalization? There are three major reasons:

  1. To get access to paths that are normally unavailable but are legal. A file or directory called hidden., for example, is impossible to access in any other way.

  2. To improve performance by skipping normalization if you've already normalized.

  3. On .NET Framework only, to skip the MAX_PATH check for path length to allow for paths that are greater than 259 characters. Most APIs allow this, with some exceptions.

Note

.NET Core and .NET 5+ handles long paths implicitly and does not perform a MAX_PATH check. The MAX_PATH check applies only to .NET Framework.

Skipping normalization and max path checks is the only difference between the two device path syntaxes; they are otherwise identical. Be careful with skipping normalization, since you can easily create paths that are difficult for 'normal' applications to deal with.

Paths that start with ? are still normalized if you explicitly pass them to the GetFullPathName function.

You can pass paths of more than MAX_PATH characters to GetFullPathName without ?. It supports arbitrary length paths up to the maximum string size that Windows can handle.

Case and the Windows file system

A peculiarity of the Windows file system that non-Windows users and developers find confusing is that path and directory names are case-insensitive. That is, directory and file names reflect the casing of the strings used when they are created. For example, the method call

creates a directory named TeStDiReCtOrY. If you rename a directory or file to change its case, the directory or file name reflects the case of the string used when you rename it. For example, the following code renames a file named test.txt to Test.txt:

However, directory and file name comparisons are case-insensitive. If you search for a file named 'test.txt', .NET file system APIs ignore case in the comparison. 'Test.txt', 'TEST.TXT', 'test.TXT', and any other combination of uppercase and lowercase letters will match 'test.txt'.

Setting the path and environment variables will differ depending on the version of Windows you have on your computer. Choose a link below for your version of Windows.

Note

Administrator privileges are usually required to modify the path and environment variables.

Setting the path and variables in Windows 10

  1. From the desktop, right-click the very bottom-left corner of the screen to get the Power User Task Menu.
  2. From the Power User Task Menu, click System.
  3. In the Settings window, scroll down to the Related settings section and click the System info link.
  4. In the System window, click the Advanced system settings link in the left navigation pane.
  5. In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
  6. In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
Note

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.

To view and set the path in the Windows command line, use the path command.

Setting the path and variables in Windows 8

  1. From the desktop, right-click the very bottom-left corner of the screen to get the Power User Task Menu.
  2. From the Power User Task Menu, click System.
  3. Click the Advanced System Settings link in the left column.
  4. In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
  5. In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
Note

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.

To view and set the path in the Windows command line, use the path command.

Setting the path and variables in Windows Vista and Windows 7

  1. From the desktop, right-click the Computer icon and select Properties. If you don't have a Computer icon on your desktop, click Start, right-click the Computer option in the Start menu, and select Properties.
  2. Click the Advanced System Settings link in the left column.
  3. In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
  4. In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
Note

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.

To view and set the path in the Windows command line, use the path command.

The Path

Setting the path and variables in Windows 2000 and Windows XP

The Path Game Download

The path is now managed by Windows 2000 and Windows XP and not the autoexec.bat or autoexec.nt files, as was done with earlier versions of Windows. To change the system environment variables, follow the steps below.

  1. From the desktop, right-click My Computer and click Properties. If you don't have a My Computer icon on your desktop, click Start, right-click the My Computer option in the Start menu, and select Properties.
  2. In the System Propertieswindow, click the Advancedtab.
  3. In the Advanced section, click the Environment Variablesbutton.
  4. In the Environment Variables window (as shown below), highlight the Path variable in the System Variable section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
Note

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.

To view and set the path in the Windows command line, use the path command.

What is the default Windows %PATH%?

The path is based on programs installed on the computer, so there is no 'default path.' However, the Windows minimum path is often the path below.

Note

Keep in mind that as you install programs, the path is updated with the paths for the newly installed programs. So, if you have erased your path after installing other programs, those programs may be affected.

Setting path in the MS-DOS and Windows command line

To view and set the path in MS-DOS and in the Windows command line, use the path command.

Additional information

  • See our environment variable definition for further information and related links.




broken image