0

This isn't really a big problem because I know I can just use a for loop but basically I have a folder with 20 images all named "Image1", "Image2", etc...

Then I wanted to add them as an attachment to an email in order using this code...

foreach (var Image in ImageFilePaths)
{
    Message.Attachments.Add(new Attachment(Image));
    Console.WriteLine(Image);
}

pretty simple, it adds them all but in the order of 1, 10-19, 2, 20, 3-9. I get why as its kind of going from smallest to biggest in a weird way, but I wanted straight up 1-20. I'm just looking for a quick fix as I know if it comes to it I can just use:

int imagecounter = 1;
for (int i = 0; i >= 20; i++)
{
    //add image path + imagecounter + jpg;
    imagecounter++
}
ChrisF
  • 134,786
  • 31
  • 255
  • 325
Jason
  • 233
  • 4
  • 17

0 Answers0