title: Image List with Next and Previous Button in Windows Form
body: <p>I am working on a Windows form. I get some images from a directory in images box with ArrayList. I load images successfully and also images show with next and previous buttons. Now I also wanna get the image URL when the image changes with buttons. I tried but unsuccessfully, here is my code:</p>
  
  <pre><code>ArrayList arylist = new ArrayList();
          int i = 0;
          int filelength = 0;
          //Initially load all your image files into the array list when form 
    load first time
          System.IO.DirectoryInfo inputDir = new DirectoryInfo("E:\\BD 
    Images");//Images Folder path
          try
          {
              if (inputDir.Exists)
              {
                  ////Get Each file
                  System.IO.FileInfo file = null;
                  foreach(System.IO.FileInfo eachfile in inputDir.GetFiles())
                  {
                      file = eachfile;
                      if(file.Extension == ".jpg")
                      {
                          arylist.Add(file.FullName);//add files in array list
                          filelength = filelength + 1;
                      }
                  }
                  BDpictureBox.Image = 
      Image.FromFile(arylist[0].ToString());//Display intially first image in 
      picture box as sero index file path
                  ImageUrltextBox.Text = file.FullName;//This line show the 
      url in text box
                  i = 0;
              }
          }
          catch(Exception ex)
          {
              MessageBox.Show("Error"+ex);
          }
  
  private void NextImagebutton_Click(object sender, EventArgs e)
      {           
          if (i + 1 &lt; filelength)
          {
              BDpictureBox.Image = Image.FromFile(arylist[i + 1].ToString());
              ImageUrltextBox.Text = file.FullName;
              i = i + 1;
  
          }
      }
  </code></pre>