Why folder or file name in Windows cannot end with space? [closed]

Posted on


I learned something new today. When I tried create new folder “folder ” (no quotes) in Visual Studio I got error:

Directory names cannot contain any of the following characters:

: * ? | ” < >

But my folder name doesn’t have any of those characters. So I tried creating this folder in Windows explorer and it strips space from end and creates folder “folder” instead of “folder “. Same does md command and same goes for file names. Why folder or file name in Windows cannot end with space?

I tried this on NTFS partition (Windows 8.1).


From Microsoft Naming Files, Paths, and Namespaces article:

Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, “.temp”.

In addition to the characters you mentioned there is also


Some of these characters are wildcard characters, and the other used in the path for the file or directory.
So, you cant use any of them in the folder or file name.

Leave a Reply

Your email address will not be published. Required fields are marked *