Tuesday, 15 September 2015

c# - remove space at the end of the line in text file -



c# - remove space at the end of the line in text file -

i have got text file contents below

wyfgemq4-iu372t5i-j0uiidad-gcojgr7z ba1111111 hosotyli-90yntvqb-2rv/rlig-bt69r0nv ba1111111 h1ulxwq4-iu2qukvr-uyuqipit-byauohn7 bg2222222 jl2mfmq4-iu1vlifn-lzmfc+bu-ibc/2ijp gc1111111 zhozpmq4-iu27lkq1-kqnlxtbt-ec28qgpr fg1111111

but unfortunately there 1 more space adding @ end of 5th line getting error when upload file ...

how can remove space ant end of 5th line (i.e) zhozpmq4-iu27lkq1-kqnlxtbt-ec28qgpr fg1111111(at here)

would 1 please help on

and code

private bool parseuploadeddoc(string strupload) { bool blresult = true; strupload = strupload.replace("\r",""); char [] delimitedchars = {'\n'}; string[] splitwords = strupload.split(delimitedchars); string[] column; stringbuilder invalidcert = new stringbuilder(); stringbuilder invalidserial = new stringbuilder(); foreach (string word in splitwords) { column = word.split('\t'); column[1].trim(); if (column[0].length != 35) { invalidcert.append(column[0].tostring()); invalidcert.append(", "); blresult = false; } /// getting error @ here if (column[1].length != 9) { invalidserial.append(column[1].tostring()); invalidserial.append(", "); blresult = false; } } if (blresult == false) { string strerrcert = "invalid certificate id(s): " + invalidcert.tostring(); strerrcert = strerrcert.substring(0, strerrcert.length - 2); lblinvalidcert.text = strerrcert; string strerrfru = "invalid serial number(s): " + invalidserial.tostring(); strerrfru = strerrfru.substring(0, strerrfru.length - 2); lblinvalidfru.text = strerrfru; } homecoming blresult; }

problem @ line

column[1].trim();

you should

column[1] = column[1].trim();

c# asp.net .net file

No comments:

Post a Comment