Con Folder Name Invalid
I know that / is illegal in Linux, and the following are illegal in Windows(I think). ' / :; =,What else am I missing?I need a comprehensive guide, however, and one that takes into accountdouble-byte characters. Linking to outside resources is fine with me.I need to first create a directory on the filesystem using a name that maycontain forbidden characters, so I plan to replace those characters withunderscores. I then need to write this directory and its contents to a zip file(using Java), so any additional advice concerning the names of zip directorieswould be appreciated.
A “comprehensive guide” of forbidden filename characters is not going to work on Windows because it reserves filenames as well as characters. Yes, characters like. '?
And others are forbidden, but there are a infinite number of names composed only of valid characters that are forbidden. For example, spaces and dots are valid filename characters, but names composed only of those characters are forbidden.Windows does not distinguish between upper-case and lower-case characters, so you cannot create a folder named A if one named a already exists. Worse, seemingly-allowed names like PRN and CON, and many others, are reserved and not allowed. Windows also has several length restrictions; a filename valid in one folder may become invalid if moved to another folder. The rules foris on MSDN.You cannot, in general, use user-generated text to create Windows directory names. If you want to allow users to name anything they want, you have to create safe names like A, AB, A2 et al., store user-generated names and their path equivalents in an application data file, and perform path mapping in your application.If you absolutely must allow user-generated folder names, the only way to tell if they are invalid is to catch exceptions and assume the name is invalid.
Con Folder Name Invalid Key
Even that is fraught with peril, as the exceptions thrown for denied access, offline drives, and out of drive space overlap with those that can be thrown for invalid names. You are opening up one huge can of hurt. Let's keep it simple and answer the question, first.The forbidden printable ASCII characters are:.Linux/Unix: / (forward slash).Windows: (greater than): (colon - sometimes works, but is actually NTFS Alternate Data Streams)' (double quote)/ (forward slash) (backslash) (vertical bar or pipe)? (question mark).
Directory File Name Invalid
(asterisk).Non-printable charactersIf your data comes from a source that would permit non-printable characters then there is more to check for.Linux/Unix: 0 (NULL byte).Windows: 0-31 (ASCII control characters)Note: While it is legal under Linux/Unix file systems to create files with control characters in the filename,.Reserved file namesThe following filenames are reserved:.Windows: CON, PRN, AUX, NULCOM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9(both on their own and with arbitrary file extensions, e.g. LPT1.txt).Other rules.Windows:Filenames cannot end in a space or dot.
Con Folder Name Invalid Download
Under Linux and other Unix-related systems, there are only two characters that cannot appear in the name of a file or directory, and those are NUL '0' and slash '/'. The slash, of course, can appear in a path name, separating directory components.Rumour 1 has it that Steven Bourne (of 'shell' fame) had a directory containing 254 files, one for every single letter (character code) that can appear in a file name (excluding /, '0'; the name. Was the current directory, of course). It was used to test the Bourne shell and routinely wrought havoc on unwary programs such as backup programs.Other people have covered the Windows rules.Note that MacOS X has a case-insensitive file system.1 It was Kernighan & Pike in who said as much in Chapter 6, Testing, §6.5 Stress Tests:When Steve Bourne was writing his Unix shell (which came to be known as the Bourne shell), he made a directory of 254 files with one-character names, one for each byte value except '0' and slash, the two characters that cannot appear in Unix file names. He used that directory for all manner of tests of pattern-matching and tokenization. (The test directory was of course created by a program.) For years afterwards, that directory was the bane of file-tree-walking programs; it tested them to destruction.Note that the directory must have contained entries. And., so it was arguably 253 files (and 2 directories), or 255 name entries, rather than 254 files.
This doesn't affect the effectiveness of the anecdote, or the careful testing it describes. Instead of creating a blacklist of characters, you could use a whitelist. As of, no simple black or white list of characters and filenames is evident among the answers to this topic - and there are many replies.The best suggestion I could come up with was to let the user name the file however he likes.
Using an error handler when the application tries to save the file, catch any exceptions, assume the filename is to blame (obviously after making sure the save path was ok as well), and prompt the user for a new file name. For best results, place this checking procedure within a loop that continues until either the user gets it right or gives up.
Worked best for me (at least in VBA).