Hey, I found your problem!
Just because the file i.jpeg was created the first time and you didn't change i (for example, increase the i if it represents a number in your case), I see you declared i as string and it means you may not want to generate next values for i as numbers?
I declared i as integer and after each snapshot being taken, I increase i by 1, and that worked perfectly.
Hope you understand your problem!
PS: If you are not careful again, this problem may still happen in the future. I means you should have someway to avoid duplicated filenames problem.
Save and Load your image
These are 2 functions to convert between Image and byte[], when insert data to your database, you should have your data as byte[] first and when you load your image data, your will get them as byte[], so you have to convert them to images before you can display them in pictureboxes.
public byte[] ImageToBytes(Image img){
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf
= new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream s = new System.IO.MemoryStream();
bf.Serialize(s,img);
byte[] data = s.GetBuffer();
s.Close();
return data;
}
public Image BytesToImage(byte[] data){
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf
= new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
MemoryStream s = new MemoryStream(data);
Image img = (Image) bf.Deserialize(s);
s.Close();
return img;
}
PS: I've not tested the code, but I think it should work. Try yourself.