我下載的圖片來自特定的URL使用for循環的情況下,一些產品有超過5個圖像..當我點擊產品按鈕一些圖像只下載並不是所有的圖像..但是當我debugg的coressponding代碼會下載所有圖像..怎麼可能......圖片沒有正確下載
這是我的代碼
for (int i = 0; i < obj.Count; i++)
{
PartNAme = (obj[i].ToString().Split('='))[1];
_prtnm = PartNAme.ToString().Split(';')[0];
_final_URI = _URI + _Prod_name + '/' + _prtnm + ".GIF";
WebClient client = new WebClient();
string strtempname = DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "");
rnd = new Random(100);
string _strfile = "PNImage" + strtempname + rnd.Next().ToString() + ".gif";
string _path = "../Images/PNImage/" + _strfile;
string _PPath = Server.MapPath(_path);
client.DownloadFile(_final_URI, _PPath);
}
我不是這方面的專家,但你有沒有嘗試過使用DownloadFileAsync? http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadfileasync(v=vs.80).aspx – 2011-06-02 05:59:49