Solved

Which characters will never appear in a file path?

Posted on 2010-11-17
8
672 Views
Last Modified: 2012-05-10
Among 256 characters, which characters will never appear in a valid file path definitely? The operating system is Windows(Language aan be Asian language or other different languages).

I belive 0x00 is one of them. But I need to know the others.
0
Comment
Question by:chcw
8 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 167 total points
Comment Utility
Full list from Microsoft

http://support.microsoft.com/kb/177506
0
 
LVL 14

Assisted Solution

by:DonConsolio
DonConsolio earned 167 total points
Comment Utility
http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx

    * < (less than)
    * > (greater than)
    * : (colon)
    * " (double quote)
    * / (forward slash)
    * \ (backslash)
    * | (vertical bar or pipe)
    * ? (question mark)
    * * (asterisk)
0
 
LVL 58

Expert Comment

by:cyberkiwi
Comment Utility
The following characters are invalid as file or folder names on Windows using NTFS:
/ ? < > \ : * | ” and any character you can type with the Ctrl key

In addition to the above illegal characters the caret ^ is also not permitted under Windows Operating Systems using the FAT file system.
0
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
backslash (\) can't appear in a (terminal) filename - but it can be part of a Windows pathname (similarly for forward slash (/) in *n*x systems).  

It wouild also be unwise (and probably not possible) to include any of the 'control code' characters in the pathname, since these usually have no graphic representation.
Control code characters are those with code-points in the range 0-31 (decimal) or 0x00-0x1f (hexadecimal)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Assisted Solution

by:antony_kibble<!-8D58D5C365651885FB5A77A120C8C8C6-->
antony_kibble<!-8D58D5C365651885FB5A77A120C8C8C6--> earned 166 total points
Comment Utility
You may use any character in the current code page (Unicode/ANSI above 127), except:

•< > : " / \ | ? *
•Characters whose integer representations are 0-31 (less than ASCII space)
•Any other character that the target file system does not allow (say, trailing periods or spaces)
•Any of the DOS names: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9 (and avoid AUX.txt, etc)
•The file name is all periods
Some optional things to check:

•File paths (including the file name) may not have more than 260 characters (that don't use the "\?\" prefix)
•Unicode file paths (including the file name) with more than 32,000 characters when using "\?\" (note that prefix may expand directory components and cause it to overflow the 32,000 limit)

You can get a list of invalid characters from Path.GetInvalidPathChars

http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars.aspx

And GetInvalidFileNameChars

http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx


0
 
LVL 8

Author Comment

by:chcw
Comment Utility
antony_kibble<!-8D58D5C3656518... :

Is there are similar function under Visual C++ 6.0 like GetInvalidPathChars?

To All:

So even for Unicode characters, the following characters will also not be permitted?

•< > : " / \ | ? *
•Characters whose integer representations are 0-31 (less than ASCII space)

Thanks
0
 
LVL 8

Author Comment

by:chcw
Comment Utility
Thanks for all your replys.

I just want to confirm that for Unicode path, the following byte will also appear in NEITHER the first byte of the Unicode character, NOR the second byte of the Unicode character, is that correct?

The following reserved characters:

< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
Integer value zero, sometimes referred to as the ASCII NUL character.
Characters whose integer representations are in the range from 1 through 31.

Thanks

0
 
LVL 8

Author Closing Comment

by:chcw
Comment Utility
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now