[Windows] windows path exploration

Source: Internet
Author: User

Windows paths are something we often use. They seem simple and actually imply many details, which are not noticed during normal use. Next let's take a look at a variety of Windows paths.

When we mention the path, we will all think of "absolute path" and "relative path". In fact, absolute path is a broad concept, which indicates the path that can be unique to locate a file or folder, there are multiple forms of paths that belong to the absolute path category, such:

Full path)

What we usually call "absolute path" usually refers to the complete path. Its format is as follows:
C: \ windows \ system32 \ calc.exe

UNC (Universal Naming Convention general naming convention) path

The UNC path is used to locate files or folders on the LAN. the UNC path is used to access shared files on other systems through network peers. The format of the UNC path is as follows:
\ Pc101 \ Program Files \ job.doc
Pc101 is the computer name of the target system, and program files is the name of the shared folder on the target system.

To \\? Path starting \

In some manually assisted antivirus tools, you can see \\? . The complete path and UNC path can both be \\? \ Start:
\\? \ C: \ windows \ system32 \ calc.exe
\\? \ UNC \ pc101 \ Program Files \ job.doc

Relative Path)

The above four paths can be used to locate an absolute file locally or on the network. Therefore, they are absolute paths. Another method we often use is relative paths. This path must work with the current directory of the process to locate a file or folder. The current folder of the process is not the folder where the EXE file is located. It is an attribute of each process. The folder where the hosts file is located remains unchanged. You can specify the current folder when the process starts. For example, the shortcut attribute contains a "start position" input box, which is the current folder after the process starts. If you do not specify the current folder of the process at startup (double-click the EXE file), the folder where the EXE file is located will serve as its current folder.

The pure relative path format is as follows:

Windows \ system32 \ calc.exe
Note that the relative path cannot start with "\". Many people think that "\" is the same. Otherwise, the path starting with "\" is another path, this path is described in detail below.

If you operateCompositionWhen a relative path is passed, the process merges the path of the current folder with the relative path to obtain a complete path. For example, the current folder of the command prompt is c: \ windows. If you execute the start system32 \ calc.exe command,ProgramThe two paths are merged to c: \ windows \ system32 \ calc.exe.
Due to this feature, the current folder is also called a working folder, because the process uses relative paths for this folder.

In addition to the pure relative paths mentioned above, there are two special relative paths. To avoid confusion, they are no longer called relative paths.

Path starting \

As mentioned above, the relative path cannot start with \. Once so, it indicates the path relative to the root directory of the current folder. For example, if the current folder of the process is c: \ windows, \ system32 \ calc.exe indicates c: \ system32 \ calc.exe. Regardless of the path of the current folder, only the root directory is used for merging. You can perform verification at the command prompt: first set C: \ windows to the current folder, and then run the start \ system32 \ calc.exe command. An error is prompted and the file cannot be found. Run the start \ windows \ system32 \ calc.exe command again. Then, the calculator program is successfully started, proving the above statement.

Path starting with drive letter and colon

This path is like a complete spelling path. Its format is as follows:
C: system32 \ calc.exe

The drive letter plus the colon is a special notation, indicating that the process is in the "current folder on the partition ". The current folder is displayed, which is different from the current folder. Simply put, for each partition, the process will save it in the current folder used at the end of the partition. If the parsing is not good enough, you can use the command prompt to perform the operation again for better understanding.

Run cmd, run the CD/d c: \ windows \ system32 command to enter the folder, switch to another partition, and then run the C: calc.exe command. You can see that the calculator program is started.

After we run the CD command to enter the c: \ windows \ system32 folder, the process uses this as the current folder. When switching to other partitions, the process first saves the path of this folder, then switch. Use the drive letter and colon to read the current folder on the specified partition.

Path restrictions

In addition to path format restrictions, there are many character restrictions. Let's take a look at the restrictions on various paths.

Except \\? In addition to the path starting with \, other paths cannot exceed 260 characters (including \ 0 characters at the end), while \\? The path starting with \ can contain about 32000 characters \\? \ The prefix may be extended to a longer string ). A technique circulating on the network: the file path is too long to be deleted. You can add \\? \ Prefix.

The last character of the file or folder name cannot be a space or a period. However, in the path, the last character can be a period, because the period in the path represents the current folder (which is completely different from the previous folder), and the two periods represent the upper-level folder. To \\? The path starting with \ cannot use periods to indicate the current folder or the upper-level folder. This can be done in the address bar of the resource manager because the Resource Manager processes the folder.

The file or folder name cannot contain characters:
<>: "/\ |? *
In the path, you can use :\?, The colon is used with the drive letter. The question mark is \\? The \ prefix is unique. In addition, the two characters cannot appear, and the \ is a folder delimiter. Although we can also use/as the separator, this is actually not allowed. The system will replace/with \ when processing the path \. In addition, 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 the UNC path:
'~ ! @ # $ % ^ & * () = + _ [] {}\ |;:. '", <> /?
It is indeed enough. In fact, we recommend that you use only 26 English letters, 10 numbers, and-(hyphens) for standard computer names. Otherwise, the computer may not be found. If a non-standard character is displayed when the computer name is changed, a prompt is displayed.

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.