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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -