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
Post a Comment