c# - how do i read strings from text files? -


I like to read the strings from the text file, the text file contains the information given below

  Con = new MySqlConnection ("server = localhost; user id = root; password =" "database = functionpling; pooling = false;");  

I like reading "root" here like "localhost", such as server name and user id "root" here, how can I read it?

this can help you

  using the system; Using System.IO; Classroom test {public static zero main () {string path = @ "c: \ temp \ MyTest.txt"; Try {if (File.Exists (Path)) {(StreamReader sr = New StreamReader (Path)) {while (sr.Peek ()> gt0 = 0) {string s = sr.ReadLine (); String [] split = s.Split (';'); // Now loop / split [0] server is divided by split array / split [1] user id}}}} hold (exception e) {console. WrightLine ("Process failed: {0}", E. wire ()); }}}  

Comments