Solved

Which characters will never appear in a file path?

Posted on 2010-11-17
8
677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Win 7 OS unable to install Win updates 3 231
Complete list of Microsoft tech support phone numbers 5 161
Python 3.5.2 32 virtualenv problems 3 101
Problem to Alipay 10 95
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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