This tip covers many things simultaneously. This tip will help in understanding
the directory and file dialog box, and also the progressbar control and image conversion.
Using the Code
I have used very simple and easy to understand code. I am saving PNG images at the same location from where the application is getting JPG images. This can be changed as per your requirements.
private void ReadJPGFiles(string path)
var files = Directory.EnumerateFiles(path).Where(p =>
Path.GetExtension(p).ToUpper() == ".JPG" ||
Path.GetExtension(p).ToUpper() == ".JPEG")
.Select(p => Path.GetFullPath(p));
progressBar1.Maximum = files.Count();
progressBar1.Value = 0;
foreach (string s in files)
progressBar1.Value += 1;
private void ConvertToPng(string path,string fileName)
Image bmpImageToConvert = Image.FromFile(path);
bmpImageToConvert.Save(FolderPath + "\\" +
fileName.Trim() + ".png", ImageFormat.Png);
- 3rd December, 2013: Initial version.