這是我的代碼:剿錯誤「主機名無法解析」
string Url = "http://illution.dk/";
WebClient Http = new WebClient();
Http.DownloadStringAsync(new Uri(Url));
Http.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetModelTypeResponse);
如果我的機器上運行這個沒有互聯網連接的錯誤將被拋出。 「主機名無法解析」
有沒有什麼辦法可以刪除這條錯誤信息?或者檢查是否沒有互聯網連接?
編輯1
try
{
ComputerInfo ComputerInfoComp = new ComputerInfo();
string Url = "http://illution.dk/"
WebClient Http = new WebClient();
Http.DownloadStringAsync(new Uri(Url));
Http.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetModelTypeResponse);
ComputerInfoComp = null;
}
catch (System.Net.WebException e)
{
//
}
謝謝,它做到了! – Fredefl