Home > Backend Development > C++ > How Can I Ensure My Filenames Are Legally Valid on Windows?

How Can I Ensure My Filenames Are Legally Valid on Windows?

Susan Sarandon
Release: 2025-01-24 16:27:09
Original
567 people have browsed it

How Can I Ensure My Filenames Are Legally Valid on Windows?

A complete guide to ensuring the legality of file names under Windows

When developing file management applications, it is crucial to verify that the filenames entered by the user comply with Windows naming conventions. However, traditional regular expressions often fall short when considering various national characters.

To solve this problem, Microsoft provides a detailed guide to legal file names under Windows systems:

Character limit:

  • Prohibited characters: ,, :, /, , |, ?, *, integers represented between 0 and 31 characters (e.g., ASCII control characters)

  • Conditional restrictions: Other characters not allowed by certain file systems (for example, trailing periods or spaces)

  • Reserved/Prohibited DOS filenames: CON, PRN, AUX, NUL, COM0 - COM9, LPT0 - LPT9 (Note: avoid files with the extension AUX.txt)

  • File path:

    • When not using the \?\ prefix, the maximum length cannot exceed 260 characters
    • Unicode file paths using the \?\ prefix can be up to 32,000 characters long, but be aware of potential expansion issues

The above is the detailed content of How Can I Ensure My Filenames Are Legally Valid on Windows?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template