Can I suggest you first read
Also read the definitions for path http://en.wikipedia.org/wiki/Path_(computing) , and be sure of what you exactly want for your application.
Trying to filter file names without the help of a OS function ? Have a look at the documentation : the device name space, network shares, transacted files, symbolink links (new in Vista), short names, long names, naming file streams, posix compliance of the supported file system, UNC naming ..., NFS name translation service will complete your despair. File names can be compressed too, in which case a regular expression is the thing you cannot use. Just to make your life a endless pursuit behind microsoft updates ...
File name and directory name length depend if you intend to use the win32 api or the windows api, it it is unicode or posix or not, or both, or if it is a local or remote file.
Then, you can build something following the recommendations in the link above
There are namespaces, but you should avoid them, because all API functions do not support them (something you cannot put in a regular expression)
There are reserved characters that you can rename anyway using a rename service (something to help bypass a regular expression)
The ~ is not mandatory for a short name
. (dot) and .. (dot)(dot) are valid characters in the name space (which you can't recognize from the directory name)
The directory name cannot exceed MAX_PATH minus 12 (unless you want to create a directory in which you will not be able to access the files)
endless, endless, endless
If you limit your textbox capabilities to the 3 examples you provided, for a us-en windows setup using a us-en codepage, and no more, you could OR the following expression
[a-z]:\\([^\Q<>:"/\|?*\E\x00]*[\Q\/\E]?)* // the specific case of a drive and path
\Q\\\E(\?\\)?([^\Q<>:"/\|?*\E\x00]*[\Q\/\E]?)* // the specific case of \\
ftp\://([^\Q\/\E\x00]*[/]?)* // the specific case of ftp:
That would be a poor result. If the local (or remote machine) is win based, you better check for not having at least the following (the list depends on the drivers is your system) at any place in the path.
I put \Q .. \E in the expressions to avoid excessive \\\ and \\\\\\\\\ escapes of escape characters. everything between \Q and \E is not interpreted. You can remove them and put the appropriate number of \ before \ if you wish.
<>:"/\|?* is the set of characters forbidden in windows (and windows only)
\x00 is the null byte (which you can use on linux, I just verified)
You replace the set [\Q<>:"/\|?*\E\x00] with \w if you want to force your user to use the ranges 0-9, a-z, A-Z and _ in the directory names, file names, server names ....at your own risks.
However, this will NOT guarantee that you will be able to open a file or use a directory. It will only guarantee that your user will have a lot of restrictions and will send you a mail when he wants to use an other type of storage device and an other file name structure.
Only 250 million inhabitants on earth use us-english. The other 6 billion always need unicode encoding at some stage.