[c#] Implement carousel images and solve the error "Insufficient memory"

Error message:

Insert image description here

reason

Insert image description here
You can see that reading the .ini file caused the error.

Solution

Find the location where the picture is stored, find the .ini file, and delete it

Since the .ini file is a file protected by the system, it is a hidden file.
How to view it
Insert image description here
Insert image description here

2. Carousel image code:
It needs to be processed with multiple threads, otherwise a single thread will not be able to display the carousel effect.

//读取图片文件夹,遍历文件夹中所有图片,加载到集合中
            string imgPath = "C:\\Users\\KK\\Pictures\\Saved Pictures";
            //将图片存到一个集合里
            string[] imgs = Directory.GetFileSystemEntries(imgPath);
            List<Image> imgList = new List<Image>();
            
            int count= imgs.Length;
            foreach (var file in imgs)
            {
    
    
                imgList.Add(Image.FromFile(file));
                
            }
            for (int i = 0;i<imgList.Count;i++)
            {
    
    
                pictureBox1.Image = imgList[i];
            }

Guess you like

Origin blog.csdn.net/KJJfighting/article/details/129956414