Windows Path Issues

Source: Internet
Author: User
Tags folder separator naming convention

Windows path is something we often use, it seems simple, actually implies a lot of details, which are not noticed in the ordinary use of the process. Let's take a look at a variety of Windows paths.

? ?

To lift the path, we all think of "absolute path" and "relative path", in fact absolute path is a broad concept, it represents a path that can uniquely locate a file or folder, there are many forms of the path is an absolute path category, for example:

Full path

The "absolute path" we usually refer to is the full path, which is in the following format:
C:\Windows\System32\calc.exe

UNC (Universal naming convention Universal Naming Convention) path

A UNC path is used to locate a file or folder on a local area network, and a UNC path is used when accessing shared files on other systems through a network neighborhood. The format of the UNC path is as follows:
\\PC101\ShareFiles\Job.doc
Where PC101 is the computer name of the target system, Sharefiles is the name of the shared folder on the target system.

Path starting with \\?\

In some hand-assisted anti-virus tools, you can see the path that starts with \\?\, and I can't find a formal name for this path. Both the full path and the UNC path can start with \\?\:
\\?\c:\windows\system32\calc.exe
\\?\unc\pc101\sharefiles\job.doc

Relative path (Relative path)

All four of the above paths can be absolutely positioned on a file locally or on the network and therefore belong to an absolute path. Another way that we often use relative paths is to work with the current directory of the process to locate a file or folder. The current folder of the process does not refer to the folder where the exe file resides, it is a property of each process. For example, the path shown at the command prompt is the current folder of the Cmd.exe process, and the CD command allows you to change the current folder, regardless of how the current folder changes, and the folder where the Cmd.exe file is located is always the same. When the process starts, you can specify its current folder, for example, in the shortcut's properties there is a "Start location" input box, which is the current folder after the process started. If you do not specify the current folder of the process at startup (directly double-clicking the exe file), the folder where the EXE file is located is used as its current folder.

? ?

The pure relative path format is as follows:

Windows\system32\calc.exe
Note that the beginning of the relative path can not have \, many people think there is no \ is the same, in fact, the path begins with \ is another path, the following details this path.

? ?

If a relative path is passed while manipulating the file in the process, the process merges the path of the current folder with the relative path, resulting in a full path. For example, the current folder at the command prompt is C:\Windows, and if you execute the start system32\calc.exe command, the program merges two paths to get C:\Windows\System32\calc.exe.
Because of this feature, the current folder is also known as a working folder, because the process uses a relative path for that folder.

? ?

In addition to the purely relative paths mentioned above, there are two special relative paths that are no longer referred to as relative paths in order to avoid confusion.

Path starting with \

As mentioned above, the relative path cannot begin with \, and once it does, it represents the path to the root of the current folder. For example, the current folder of a process is C:\Windows, then \system32 \calc.exe represents C:\System32\calc.exe. Merges only the root directory, regardless of how deep the current folder's path is. You can verify at the command prompt: first set C:\Windows to the current folder, and then execute the start \system32\calc.exe command, you will be prompted with an error and the file cannot be found. Then execute the start \windows\system32\calc.exe command, when the calculator program successfully started, proving the above statement.

Path starting with a letter and a colon

This path is like the full path to the spelling error, which is in the following format:
C:system32\calc.exe

Disk multibyte a colon is a special notation that represents the process in the current folder on this partition. It's popping up again. A current folder, which is different from the current folder above. Simply put, for each partition, the process will save the last current folder used on this partition. may not resolve well enough, you can use the command prompt to manipulate it to deepen your understanding.

? ?

Run cmd, execute the cd/d C:\Windows\System32 command to enter the folder, then switch to the other partition, and then execute the c:calc.exe command, you can see the calculator program started.

? ?

After we execute the CD command to enter the C:\Windows\System32 folder, the process takes this as the current folder, and when you switch to the remaining partitions, the process saves the path to the folder before switching. Reads the current folder on the specified partition using the drive letter and colon.

Restrictions in the path

In addition to the restrictions on the path format, there are many restrictions on the character, below hit to see what the various paths have restrictions.

? ?

In addition to the path that begins with \\?\, the length of the other path cannot exceed 260 characters (including the end of the \ \\?\ character), and the length of the path at the beginning of the 32000 can be up to a few characters (the system may extend it to a longer string when processing the \\?\ prefix). A trick spread on the Web: The file path is too long to be deleted, and you can prefix the path with the \\?\ before executing the del command.

? ?

The last character of a file or folder name cannot be a space or a period. In the path, however, the last character can be a period, because the period in the path represents the current folder (which is completely different from the present folder above), and two periods represent the top-level folder. You cannot use a period in a path that starts with \\?\ to represent the current folder or a previous level folder, although you can do so in the address bar of the explorer, because the resource manager handles it.

? ?

The file or folder name cannot contain characters:
< >: "/\ |? *
Can be used in the path: \?, the colon is used with the drive letter, the question mark is unique in the \\?\ prefix, except that the two characters cannot appear, and \ is the folder separator. Although we can also use/as separators, which is not allowed in practice, the system will be/replaced by \ When processing the path. Also, if the last character of the path is \, the path represents a folder, otherwise it represents a file.

? ?

The following characters cannot appear in the Computer name section of a UNC path:
` ~ ! @ # $% ^ & * () = + _ [] {} \ |; : . ', < >/?
Indeed, it is true that the standard computer name is recommended to use only 26 English letters, 10 digits, and-(hyphens), otherwise the computer may not be found. If non-standard characters appear when changing the computer name, the system prompts you.

Windows Path Issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.