1

I've to download the images from particular URL using , for loop in case some products having more than 5 images .. when i click the product button some of the images only getting download not all images..but when i debug the corresponding code works fine, i.e, its downloads all the images..properly . is this due to some cache .... or image file is in Gif format....

This is My Code

for (int i = 0; i < obj.Count; i++)
{
PartNAme = (obj[i].ToString().Split('='))[1];
_prtnm = PartNAme.ToString().Split(';')[0];

//this is url , source for the image
_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);

//to download image from source url, and path to save the image file
client.DownloadFile(_final_URI, _PPath);
}

in above code when i debug the image files are getting downloaded properly, but while running without debug some image files gets repeated so instead of getting original image file , old/same image file gets downloaded instead... is this due to some cache .... or image file is in Gif format....

Mark Kram
  • 5,672
  • 7
  • 51
  • 70
anbu senthil
  • 21
  • 1
  • 5

1 Answers1

0

I think that random gives you the same number. See this thread for a fix Random number generator only generating one random number

If you debug you are way "slower" that without debugging. Another option would be to use guids as filename

Community
  • 1
  • 1
Ivo
  • 3,406
  • 4
  • 33
  • 56