c# - Start index cannot be larger than the length of the string -
i'm trying check if foldername doesn't have extension.
because want change name of folder.
can change name of file.
and error:
"startindex cannot larger length of string.\r\nparameter name: startindex"} by line:
string newfilenameextension = path.getextension(model.filename.trim()).substring(1); how check if foldername has no extension?
you should have code in following way -
string newfilenameextension = path.getextension("sample".trim()); string extn = string.empty; if (!string.isnullorwhitespace(newfilenameextension)) { extn = newfilenameextension.substring(1); } if(!string.isnullorwhitespace(extn)) { // use extn here }
Comments
Post a Comment