c# - How to append to a text in a file -



c# - How to append to a text in a file -

i have file has next contents:

class="lang-none prettyprint-override">#mon jun 16 14:47:57 edt 2014 downloaddir=download userid=1111113 inputurl=https\://sdfsfd.com dbid=1212 verificationurl=https\://check.a.com downloadlistfile=some.lst uploadlistfile=some1.lst outputurl=https\://sd.com password=bvfsds3232sdcffr

i open file , modify contents, add together |test only end of userid. edited file this:

class="lang-none prettyprint-override">#mon jun 16 14:47:57 edt 2014 downloaddir=download userid=1111113|test inputurl=https\://sdfsfd.com dbid=1212 verificationurl=https\://check.a.com downloadlistfile=some.lst uploadlistfile=some1.lst outputurl=https\://sd.com password=bvfsds3232sdcffr

how can accomplish it?

i far have ability read lines file. have:

class="lang-cs prettyprint-override">if (file.exists(strrootpropertyfile)) { string[] lines = null; seek { lines = file.readalllines(strrootpropertyfile); } grab (exception ex) { messagebox.show(ex.message); } if (lines != null) { //find line userid //add `|test only` @ end of userid //overwrite file... } }

you loop between lines , check if line start "userid=" string , add together string need. after it, create new file , overwrite current file using file.writealltext() method, , string.join using environment.newline (break line) separator.

if (file.exists(strrootpropertyfile)) { string[] lines = null; seek { lines = file.readalllines(strrootpropertyfile); } grab (exception ex) { messagebox.show(ex.message); } if (lines != null) { for(int = 0; < lines.length; i++) if (lines[i].startwith("userid=")) lines[i] += "|test only"; file.writealltext(strrootpropertyfile, string.join(environment.newline, lines)); } }

c# file

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -