Feb 28, 2014

Display picture from folder in c#.net

//<DisplayPicture>
//Display picture from folder i.e saved picture 
try
{
string[] images = Directory.GetFiles(Application.StartupPath + "\\images\\", "*.jpg");
string picName="softtechsolving.jpg"; //here softtechsolving.jpg is search items
string picName1 = picName;
int index = 0;
foreach (string file in images)
{
    try
    {
        string hasPicName = Path.GetFileName(file).ToString();
        if (hasPicName.ToString() == picName1.ToString())
        {


            Image image = Image.FromFile(images[index]);
            pictureBox1.Width = 100;
            pictureBox1.Height = 79;
            pictureBox1.Image = image;
        }
    }
    catch { }
    index = index + 1;
}
}
catch { }

//</DisplayPicture>