Hllo everyone. I am Gabriel from Romania (sorry for my bad english)
My problem is: I have 3 listbox (1.ID 2.Online ID 3.Offline id)
Now... From a .txt file or from a button an id/id`s are inserted in listbox 1.
A second button "check status" verifies if these id`s are on or off and then pass in listbox online if are online or listbox offline if offline.. hope you understand what i want to do... i must use webclient and opi from yahoo as a condition

private void btnCheckStatus_Click(object sender, EventArgs e)
        {
            HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://opi.yahoo.com/online?u=Id&m=0&t=0");
            request.CachePolicy = policy;
            Stream stream = request.GetResponse().GetResponseStream();
            byte[] buffer = new byte[1024];
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            String st = Encoding.ASCII.GetString(buffer, 0, buffer.Length);

            int count = listBox1.Items.Count;

            for (int i = 0; i <= listBox1.Items.Count-1; i++)
            {
                if (count != 0)
                {
                    listBox2.Items.Add(listBox1.SelectedItems[i]);
                }
                else
                {
                    listBox3.Items.Add(listBox1.SelectedItems[i]);
                }
                listBox1.SelectedItems.Clear(); 
            }

        }

this is my code ... but i know is wrong :|
help please....

now my code look like this.... but still wrong, i think

private bool isList1(String item)
        {
            if (item.StartsWith("http://opi.yahoo.com/online" + "?u=" + listBox1.Items + "Id&m=0&t=0"))
            {
                return true;
            }

            return false;
        }


        private void btnCheckStatus_Click(object sender, EventArgs e)
        {
            HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://opi.yahoo.com/online?u=Id&m=0&t=0");
            request.CachePolicy = policy;
            Stream stream = request.GetResponse().GetResponseStream();
            byte[] buffer = new byte[1024];
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            String st = Encoding.ASCII.GetString(buffer, 0, buffer.Length);

            foreach (String name in listBox1.Items)
            {

                if (isList1(name))
                {
                    listBox2.Items.Add(name);
                }
                else
                {
                    listBox3.Items.Add(name);
                }
            }
            listBox1.Items.Clear();

        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.