1
我在一個網站上製作這個文件夾掃描儀, ,但在2個成功的網址後,它會崩潰,我不知道爲什麼。檢查網絡服務器的響應
if (File.Exists(filePath))
{
StreamReader file = null;
file = new StreamReader(filePath);
while ((line = file.ReadLine()) != null)
{
var url = new Uri(txtUrl.Text + line);
try
{
var request = (HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)";
var response = (HttpWebResponse)request.GetResponse();
//Directory.ListView.Items.Add(url.ToString());
MessageBox.Show(url.ToString() + "Success");
}
catch (Exception err)
{
MessageBox.Show(url.ToString() + " fail: " + err.Message);
}
}
if (file != null)
file.Close();
MessageBox.Show("done;");
}
你可以發佈你正在試圖讀取該文件的內容? – 2011-02-17 23:53:40