diff --git a/docs/standard/io/file-path-formats.md b/docs/standard/io/file-path-formats.md index a822ea60624c7..50c960aaa5c2d 100644 --- a/docs/standard/io/file-path-formats.md +++ b/docs/standard/io/file-path-formats.md @@ -11,6 +11,7 @@ helpviewer_keywords: - "path formats, Windows" ai-usage: ai-assisted --- + # File path formats on Windows systems Members of many of the types in the 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](/windows/desktop/fileio/file-systems). This topic discusses the formats for file paths that you can use on Windows systems. @@ -25,8 +26,8 @@ A standard DOS path can consist of three components: 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. -|Path |Description | -| -- | -- | +| Path | Description | +| --- | --- | | `C:\Documents\Newsletters\Summer2018.pdf` | An absolute file path from the root of drive `C:`. | | `\Program Files\Custom Utilities\StringFinder.exe` | A relative path from the root of the current drive. | | `2018\January.xlsx` | A relative path to a file in a subdirectory of the current directory. | @@ -55,10 +56,10 @@ Universal naming convention (UNC) paths, which are used to access network resour The following are some examples of UNC paths: -|Path |Description | -| -- | -- | +| Path | Description | +| --- | --- | | `\\system07\C$\` | The root directory of the `C:` drive on `system07`. | -| `\\Server2\Share\Test\Foo.txt` | The `Foo.txt` file in the Test directory of the `\\Server2\Share` volume.| +| `\\Server2\Share\Test\Foo.txt` | The `Foo.txt` file in the Test directory of the `\\Server2\Share` 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. @@ -66,13 +67,13 @@ UNC paths must always be fully qualified. They can include relative directory se 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:\Test\Foo.txt` -`\\?\C:\Test\Foo.txt` +- `\\.\C:\Test\Foo.txt` +- `\\?\C:\Test\Foo.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}\Test\Foo.txt` -`\\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.txt` +- `\\.\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.txt` +- `\\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.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. @@ -81,19 +82,19 @@ 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. + > [!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\`.) + 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: + There is a specific link for UNCs that is called, not surprisingly, `UNC`. For example: - `\\.\UNC\Server\Share\Test\Foo.txt` - `\\?\UNC\Server\Share\Test\Foo.txt` + - `\\.\UNC\Server\Share\Test\Foo.txt` + - `\\?\UNC\Server\Share\Test\Foo.txt` - For device UNCs, the server/share portion forms the volume. For example, in `\\?\server1\utilities\\filecomparer\`, the server/share portion is `server1\utilities`. This is significant when calling a method such as with relative directory segments; it is never possible to navigate past the volume. + For device UNCs, the server/share portion forms the volume. For example, in `\\?\server1\utilities\\filecomparer\`, the server/share portion is `server1\utilities`. This is significant when calling a method such as with relative directory segments; it is never possible to navigate past the volume. DOS device paths are fully qualified by definition and can't begin with a relative directory segment (`.` or `..`). Current directories never enter into their usage. @@ -164,7 +165,7 @@ As the path is processed, any components or segments that are composed of a sing - 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 (`\\Server\Share`), and the device path prefix for device paths (`\\?\` or `\\.\`). + 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 (`\\Server\Share`), and the device path prefix for device paths (`\\?\` or `\\.\`). ### Trim characters @@ -174,10 +175,10 @@ Along with the runs of separators and relative segments removed earlier, some ad - 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. + 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. + > [!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