c# - How do I check if a given string is a legal / valid file name under Windows? -


i want include batch file rename functionality in application. user can type destination filename pattern , (after replacing wildcards in pattern) need check if it's going legal filename under windows. i've tried use regular expression [a-za-z0-9_]+ doesn't include many national-specific characters various languages (e.g. umlauts , on). best way such check?

you can list of invalid characters path.getinvalidpathchars , getinvalidfilenamechars.

upd: see steve cooper's suggestion on how use these in regular expression.

upd2: note according remarks section in msdn "the array returned method not guaranteed contain complete set of characters invalid in file , directory names." the answer provided sixlettervaliables goes more details.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -