using System.Text;using System.Windows.Forms;using System.Collections;namespace WindowsFormsApplication15{ public partial class Form1 : Form { ArrayList alist = new ArrayList(); int i = 0; int filecount = 0; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //Specify Source folder path here System.IO.DirectoryInfo inputDir = new System.IO.DirectoryInfo("D:\\images"); try { if ((inputDir.Exists)) { //Get Each jpg files from a source folder and stored in the arraylist System.IO.FileInfo file = null; foreach (System.IO.FileInfo eachfile in inputDir.GetFiles()) { file = eachfile; if (file.Extension.ToLower() == ".jpg") { alist.Add(file.FullName); //Store file count here filecount = filecount + 1; } } //Initally show first image in the picture box pictureBox1.Image = Image.FromFile(alist[0].ToString()); ; i = 0; } } catch (Exception ex) { } } private void btnNext_Click(object sender, EventArgs e) { //check next postion image is have or not if (i + 1 < filecount) { pictureBox1.Image = Image.FromFile(alist[i + 1].ToString()) ; i = i + 1; } } private void btnPrevious_Click(object sender, EventArgs e) { //check previous postion image is have or not if (i - 1 >= 0) { pictureBox1.Image = Image.FromFile(alist[i-1].ToString()) ; i = i - 1 ; } } }}