[Windows] Naming rules when creating a new file or folder

First, the purpose

Know what characters can be used in file or folder names.

2. Analysis

The first is the windows prompt:

 2.1 Rules

  1. The entire content cannot contain:

    1. slash /
    2. backslash \
    3. English colon :
    4. Multiplication sign (asterisk) *
    5. English question mark ?
    6. English double quotes "
    7. left and right angle brackets <>
    8. or logical symbols |
    9. The reason is to guess that when Windows grabs the file name, each name is concatenated to form a string, and it is distinguished by a backslash. When searching for a file in a regular pattern, in order to avoid a regular pattern capture failure, the regular pattern related symbols cannot be used. In the string description In the C language, double quotes are used to distinguish character strings, so double quotes cannot be used, or in the windows system, double quotes are used to lock the address to prevent tampering, and left and right angle brackets are used in the command line.
  2. The first and last letters cannot contain

    1. Spaces, Chinese and English spaces cannot be included at the beginning and end. Although they can be written, they will not be stored.
  3. other characters

    1. It can be written by a program, and can form a file that cannot be deleted or a file that cannot display a name
    2. unicode control characters can be inserted to form non-displayable filenames
  4. length rule

    1. Basic rules The length of the full name combined should not exceed 255 characters
    2. An example of creating a folder is shown in the figure:
    3. This is the most extreme situation where a folder can be created. To explain: To create a folder, the following conditions must be met: the length of the name of the current folder (242) + a backslash in the file to be created Path (1) + default name "new folder" (10) + a backslash path into the new folder (1) + keep at least one character name under this path (1) together constitute 255 limit cases.
    4. An example of creating a file is shown in the figure:
    5. The file created at this time has no initial name, and there will be no warning that a name must be entered:
    6. So this method can generate an unnamed file:
  5. Other rules:

    1. The above restrictions are limited to the creation stage. When the file name of the parent directory is too long after creation, the creation of new files in its subdirectory can be prohibited. But reading and writing the contents of the file under the long path is normal.
  6. Rules that cannot be deleted:
    1. When the above operation contains files beyond 255 paths, the entire folder cannot be deleted, and the file name can be shortened by moving or modifying the name and then deleted.

3. Summary

It is much better to understand the path problem in the form of a string. If the path is a string first, the path must be mutually exclusive with the regular expression, and the length data is represented by one byte, 0xff is 255 length.

Hey, Silver Sparrow Sting.

Guess you like

Origin blog.csdn.net/qq_34217861/article/details/126156233