c# - read line from text file then How show line 1st word textbox1 until : symbol then 2nd textbox show after : symbol? -
my have below process 1 .txt file
firstname:lastname sumon:kamal abdul:halim kamrul:khan rafiq: akbor
how show 1st name textbox1 2nd textbox show last name?
example clear
textbox1 show sumon & textbox2 show kamal
i trying more road still not getting road this.
i trying using streamreader show textbox data full line coming.
how reading 1 line 2 textbox both name?
if take question right, want this.
public partial class main : form { private const string path = "c:\\person.txt"; public main() { initializecomponent(); // read lines file @ specified path var lines = file.readlines(path); // take first line aquired collection var line = lines.firstordefault(); if (line == null) return; // split string first , last names var parts = line.split(':'); if (parts.length != 2) return; // send them textbox.text property textbox1.text = parts[0]; textbox2.text = parts[1]; } }
don't forget drop textbox1 , textbox2 form. iterate on lines if need else.
Comments
Post a Comment