Solved

Which characters will never appear in a file path?

Posted on 2010-11-17
8
673 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
ID: 34153676
Full list from Microsoft

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

Assisted Solution

by:DonConsolio
DonConsolio earned 167 total points
ID: 34153682
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
ID: 34153692
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
ID: 34153716
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 12

Assisted Solution

by:antony_kibble<!-8D58D5C365651885FB5A77A120C8C8C6-->
antony_kibble<!-8D58D5C365651885FB5A77A120C8C8C6--> earned 166 total points
ID: 34153792
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
ID: 34185261
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
ID: 34185287
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
ID: 34280916
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adobe Customization Wizard XI issues 26 210
How to make a exe file from access 2013 database 5 158
Moving SharePoint 3.0 role to differen server 7 47
Problem to page 4 74
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

920 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

12 Experts available now in Live!

Get 1:1 Help Now