Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Read from textfile and fill in textbox

private void Form1_Load(object sender, EventArgs e)
{
    string line = "";
    System.IO.StreamReader file = new System.IO.StreamReader(@"FilePathWithNameAndExtension");
    while (!file.EndOfStream)
    {
        line += file.ReadLine() + "&"; //adding distinct value so that we can split them as a line.
    }
    string[] newLines = line.Split('&'); //storing lines in array.
    txtUserName.Text = newLines[1].Split(':')[1].ToString(); //newLines[1] represent to UserName that means we will extract from second line which is storing the username.
    txtCountry.Text = newLines[2].Split(':')[1].ToString();
    txtMemberShip.Text = newLines[3].Split(':')[1].ToString();
}
Source by www.aspsnippets.com #
 
PREVIOUS NEXT
Tagged: #Read #textfile #fill #textbox
ADD COMMENT
Topic
Name
7+4 =