c# - File name validation -
i check file name validation in following way:
foreach (char c in system.io.path.getinvalidfilenamechars()) { validfilename = validfilename.replace(c, '_'); }
is there faster way do so?
this might faster, hardly think original slow enough care about...
var invalidchars = path.getinvalidfilenamechars(); var filenamechars = validfilename.tochararray(); (int = 0; < filenamechars.length; ++i) if (invalidchars.contains(filenamechars[i])) filenamechars[i] = '_'; validfilename = new string(filenamechars);
Comments
Post a Comment