This function gives you a list of invalid characters for the file name. It is up to you to verify that your file name does not contain:
public static char[] Path.GetInvalidFileNameChars()
The docs are here .
Note that if you want to check the directory name, you must use GetInvalidPathChars() .
EDIT: Oooo! Sorry, I thought you were on .NET. Using Reflector, here these functions come down to the following:
'"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b', '\x001c', '\x001d', '\x001e', '\x001f', ':', '*', '?', '\\', '/'
Please note: in addition, there are reserved names such as prn, con, com1, com2,... , lpt1, lpt2,...