嗨,我使用下面的代码检查 5 个 url,但如果 ex: url no 3 is 404 not found 代码将停止检查第 4 个 url,无论如何我可以让代码运行直到 url 列表完成?
private void button2_Click(object sender, EventArgs e)
{
try
{
for (i = 0; i < listBox1.Items.Count; i++)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(listBox1.Items[i].ToString());
if (response.StatusCode == HttpStatusCode.OK)
{
listBox3.Items.Add(listBox1.Items[i].ToString());
}
}
}
catch (WebException x)
{
}
}