c# - How to read one txt file into several textboxes by a button(in different order)? -


for example: if txt file's contents aaa|bbb|ccc. i'd use button distribute aaa textbox2, bbb textbox5, cccto textbox3 . how make it? have try lots of ways solve ,but still doesn't work.please~

if text file content this.

aaaa|bbb|cccc dddd|eee|ffff 

then can try this.

private void button1_click(object sender, eventargs e)     {         textbox1.multiline = true;         textbox2.multiline = true;         textbox3.multiline = true;         stringbuilder sb1 = new stringbuilder();         stringbuilder sb2 = new stringbuilder();         stringbuilder sb3 = new stringbuilder();        var lines =   file.readalllines("d:\\sample.txt");        foreach (var line in lines)         {             var splits = line.split("|".tochararray(), stringsplitoptions.removeemptyentries);            if (splits.length > 2) {                sb1.append(splits[0] + environment.newline);                sb2.append(splits[1] + environment.newline);                sb3.append(splits[2] + environment.newline);            }          }        textbox1.text = sb1.tostring();        textbox2.text = sb2.tostring();        textbox3.text = sb3.tostring();     } 

out this.

enter image description here


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -