I have to get a text file from the server and then read the file and save it in the dictionary on the client.
I read the file, but I'm not sure how to extract the information from the file and save it in the dictionary from here.
My text file contains the following data:
Amy; 10.30; one hundred; $ 7
Bandy; 4.30; one hundred; $ 9
Bobby; 3.20; 80; $ 7
Client code
private static void loadMovies() { try { byte[] data = new byte[1024]; writer.WriteLine(BROWSE); writer.Flush(); while (true) { data = ReceiveMovieData(server); MemoryStream ms = new MemoryStream(data); loadMovies(); break; } } catch (Exception ex) { //textBox1.Text = ex.Message; } } private static byte[] ReceiveMovieData(Socket s) { int total = 0; int recv; byte[] datasize = new byte[4]; recv = s.Receive(datasize, 0, 4, 0); int size = BitConverter.ToInt32(datasize, 0); int dataleft = size; byte[] data = new byte[size]; while (total < size) { recv = s.Receive(data, total, dataleft, 0); if (recv == 0) { break; } total += recv; dataleft -= recv; } return data; }
user4840466
source share