Powered By Blogger

C#SHARP ANSWER

Friday, June 24, 2011

extracting all .jpg images from a folder

trying to extract all the images from a folder then follow up the following code and extract all the .jpg images from a folder

 String[] athar = Directory.GetFiles(@"D:\\", "*.JPG");
        PictureBox[] pb = new PictureBox[300];

int j = 100, l = 0,k=0;
    for (k=0; k <300; k++)
    {
        pb[k] = new PictureBox();
        if (k % 5 == 0)
        {
            j += 200;
            l = 0;
        }
        pb[k].Location = new Point((l * 190) + 200, j);
        pb[k].Size = new Size(150, 100);
        pb[k].SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
        pb[k].BackColor = Color.Black;
        pb[k].BorderStyle = BorderStyle.FixedSingle;
        pb[k].Image = Image.FromFile(athar[k]);
        pb[k].Visible = true;
        this.Controls.Add(pb[k]);
        pb[k].Cursor = System.Windows.Forms.Cursors.Hand;

        // Panel1.Controls.Add(pb[i]);

        pb[k].BringToFront();
      l++;
    }