Error message:
reason
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
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];
}