How to split data in a text file in C#.This is how my data looks: name: abcsurname: abctel:1234 and
- by userJD
`public void SeparateData()
{
//read file
StreamReader sr = new StreamReader("myTextFile.txt");
//string to hold line
string myline;
myline = sr.ReadLine();
while ((myline = sr.ReadLine()) != null)
{
string[] lines = Regex.Split(myline, " ");
foreach (string s in lines)
{
using (StreamWriter sw = new StreamWriter("myTextFile.txt"))
sw.WriteLine(lines);
}
}
} `