I am loading a List<Image> from a folder about 250 images in size. I did a DateTime comparison, and it takes only 11 seconds to download these 250 images. Itβs slow, damn it, and I would really like to speed it up.
Images are on my local hard drive, not even on an external one.
The code:
DialogResult dr = imageFolderBrowser.ShowDialog(); if(dr == DialogResult.OK) { DateTime start = DateTime.Now; //Get all images in the folder and place them in a List<> files = Directory.GetFiles(imageFolderBrowser.SelectedPath); foreach(string file in files) { sourceImages.Add(Image.FromFile(file)); } DateTime end = DateTime.Now; timeLabel.Text = end.Subtract(start).TotalMilliseconds.ToString(); }
EDIT: yes, I need all the pictures. What I'm planning is to take a center of 30 pixels for each of them and make a new image out of it. Kinda like a 360 degree image. Only now I'm just testing with random images.
I know that there is probably a better framework for this, but I need this to work in the first place.
EDIT2: switches to a stopwatch, the difference is only a few milliseconds. Also tried it with Directory.EnumerateFiles, but there was no difference at all.
EDIT3: I am running .NET 4 on a 32-bit Win7 client.
c # generic-list
Kdgdev
source share