I have a for loop that loops with a listbox. For each item in the listbox I want to perform a httpwebrequest. My loop is doing the first item then occasionally just iterates down the list not doing the httpwebrequest for the other items. Im not sure if theres not enough time between requests or something.
Maybe you can help. I removed my postdata and sites I request to on purpose:
listBox4.SetSelected(i, true);
listBox5.SetSelected(i, true);
listBox4.SelectedItem.ToString();
string[] details = { listBox4.SelectedItem.ToString(), listBox5.SelectedItem.ToString() };
foreach (string element in details)
{
Thread.Sleep(400);
System.Net.ServicePointManager.Expect100Continue = false;
string postdata = "";
UTF8Encoding encoding1 = new UTF8Encoding();
byte[] bytedata = encoding1.GetBytes(postdata);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");
request.Method = "POST";
request.KeepAlive = false;
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "";
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6";
request.ContentLength = bytedata.Length;
Stream postreqstream2 = request.GetRequestStream();
postreqstream2.Write(bytedata, 0, bytedata.Length);
postreqstream2.Close();
HttpWebResponse response = default(HttpWebResponse);
response = (HttpWebResponse)request.GetResponse();
StreamReader reader2 = new StreamReader(response.GetResponseStream());
string twitter = reader2.ReadToEnd();
richTextBox1.Text = twitter;
webBrowser1.DocumentText = (richTextBox1.Text);
toolStripStatusLabel1.Text = "Idle";
listBox6.Items.Add(listBox5.SelectedItem.ToString() + ":" + txtBoxImportPasswords.Text + "\r");
reader2.Close();
reader2.Dispose();