Home > Backend Development > C++ > How Can I Check if a String is a Valid Windows File Name?

How Can I Check if a String is a Valid Windows File Name?

DDD
Release: 2025-01-24 16:21:10
Original
1048 people have browsed it

How Can I Check if a String is a Valid Windows File Name?

Verification of file name validity under Windows system

On Windows systems, to verify whether a given string is a valid file name, you need to follow the established naming convention. These conventions state that the file name must be:

Prohibited characters:

  • Less than sign (<)
  • Characters with ASCII value less than 31, including line breaks
  • Forward slash (/), backslash (), colon (:), vertical bar (|), question mark (?) and asterisk (*)
  • Reserved DOS device names: CON, PRN, AUX, NUL, COM1-9, LPT1-9

Other inspections:

  • The file path containing the file name should not exceed 260 characters without using the extended path ?\ prefix.
  • Unicode file paths using ?\ may exceed 32,000 characters, but directory expansion may cause overflow.
  • File names should not consist of periods only.

The above is the detailed content of How Can I Check if a String is a Valid Windows File Name?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template