Trying to deduce the version does not work, help! Code:

string str = String.Empty; private void vertest() { try { string ts = "http://frostsecurity.net/frost/frostupdater/version.txt"; HttpWebRequest p = (HttpWebRequest)WebRequest.Create(ts); Stream z = ((HttpWebResponse)p.GetResponse()).GetResponseStream(); new List<string>(); using (StreamReader v = new StreamReader(z, Encoding.UTF8)) { while (v.Peek() >= 1) { string x = v.ReadLine(); if (x.Contains("pb_live")) { ver = str; this.Frost.Text = x.Split(new char[] { '|' })[1]; } } } } catch { } } // Интересует сама строка:из pblive 3.0.0.27 

Closed due to the fact that off-topic participants Dmitriy Simushev , rdorn , Nick Volynkin Jun 6 '16 at 4:31 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Dmitriy Simushev, Nick Volynkin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    And what do you think the string does is the new List<string>(); ? - VladD
  • Yes, I stupidly tore the code from the left application, I really do not understand much, I am learning from those who know) ... Tell me what's wrong? - TriX
  • 3
    Yes. She does nothing. Would you read the book, huh? - VladD
  • Certainly with time) .. and about the list, is it possible to solve it somehow? - TriX
  • one
    For the beginning, did you go there, buddy? An example that does nothing from the left application. what? - strangeqargo

1 answer 1

Here is a little LINQ:

 var uri = new Uri("http://frostsecurity.net/frost/frostupdater/version.txt"); var request = WebRequest.CreateHttp(uri); using (var responce = (HttpWebResponse)request.GetResponse()) using (var responceStream = responce.GetResponseStream()) using (var reader = new StreamReader(responceStream)) { var dict = reader.ReadToEnd() .Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries) .Select(l => l.Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries)) .ToDictionary(a => a[0], a => a[1]); var result = dict["pb_live"]; } 

Keep without LINQ, here's the inside.

  var dict = new Dictionary<string, string>(); string line; while ((line = reader.ReadLine()) != null) { if (string.IsNullOrWhiteSpace(line)) continue; var parts = line.Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries); dict[parts[0]] = parts[1]; } var result = dict["pb_live"]; 

And read the book , developing by asking questions on SO does not justify itself.

  • And on 3.5 framework'e without LINQ? - TriX
  • one
    @TriX: This is an additional condition. Moreover, the code is obviously translated into code without LINQ. - VladD
  • If I knew) - TriX
  • I would be very grateful for the detailed answer! Use without LINQ. - TriX
  • @TriX: Well, keep without LINQ. - VladD 2:42 pm