Im trying to insert items to a listbox from a text file hosted on my webserver. The text file looks like this:
1:game="x":image="y":
2:game="x2":image="y2":
What Im trying to achieve is to separate the strings AND have the textbox to display multiple items like this:
x
x2
The most important part is, if I added a new line such as "3:game="x3":image="y3":" to my webserver textfile, It'd also have to get that added into the listBox automatically, WITHOUT having to modify the code.
This is the way Im retrieving the string:
string RetrieveList;
WebClient con = new WebClient();
RetrieveList = con.DownloadString("webserver.abc/textfile.txt");
gameList.Items.Add(RetrieveList);
Edit: Figured it out with the help of @David.Warwick
string RetrieveList;
WebClient con = new WebClient();
RetrieveList = con.DownloadString("com.com/data.txt");
string[] sLines = RetrieveList.Split('*'); //split on each new line
foreach (string sLine in sLines)
{
string sGameValue = sLine.Split(',')[0];
gameList.Items.Add(sGameValue);
}
I just changed my text file to be separated with ","'s.