Solved

Which characters will never appear in a file path?

Posted on 2010-11-17
8
676 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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
 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 116
Python 3.5.2 32 virtualenv problems 3 68
Reccomended programming language for client-server applications 12 132
SharePoint 2013 URL Duplication Issue 5 25
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

830 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