I am implementing a code which uses the FolderBrowserDialog control. Here is my code :

FolderBrowserDialog folder = new FolderBrowserDialog();
            DialogResult result = folder.ShowDialog();
            if (result == DialogResult.OK)
                    string path = folder.SelectedPath;
                    string[] files = Directory.GetFiles(path, "*.jpeg");
foreach (string file in files)
using (Stream s = File.Open(file, FileMode.Open))
                            srcImage = Bitmap.FromStream(s) as Bitmap;
                        this.pictureBox1.Image = srcImage;
                        this.pictureBox1.Width = this.pictureBox1.Image.Width;
                        this.pictureBox1.Height = this.pictureBox1.Image.Height;
//do something else

What I am basically trying to do is, I read the images in the selected folder and perform some operations on each image(this part worked fine so far). The trouble is that this coding takes only one image from the folder and performs the operations and terminates. The rest of the images are not considered. Any ideas why it happens like this

On line 8 of your code did you try
string[] files = Directory.GetFiles(path, "*.jpg"); ?
An image file can be a JPEG file, but the extension is .jpg
3 letter extensions comes from a time when dinosaurs still lived...

yes ddanbe is right you can change this,and it will fix your problem.........

For ur info, I tried both with jpg initially... it didnt work.. then only i tried with jpeg(to test) and it still didnt work

If three letter extensions existed from a time when dinosaurs still existed, I am sure such problems have also existed since then. :)

Ok, I figured out the problem. An exception is thrown, which was caught, but since I didnt give any code there, it didnt disply the exception.

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)

Ok, I got it to work. I worked out a way to handle the mechanism