I'm currently working on windows form application which allow user to retrieve image after searching at textbox. The problem is the image is load very slow. How can I overcome this problem to speed up the loading? If anyone has suggestions for a faster way to retrieve these images, it would be greatly appreciated. Here is my code:
- string baseFolder = @"\\\\jun01\\hr\\photo";
- string imgName = "*" + textBoxEmplNo.Text + "*.jpg";
- //Bool to see if file is found after checking all
- bool fileFound = false;
- DirectoryInfo di = new DirectoryInfo(baseFolder);
- foreach (var file in di.GetFiles(imgName, SearchOption.AllDirectories))
- {
- pictureBox1.Visible = true;
- pictureBox1.Image = Image.FromFile(file.FullName);
- fileFound = true;
- break;
- }
- if (!fileFound)
- {
- pictureBox1.Visible = true;
- pictureBox1.Image = Image.FromFile(@"\\\\jun01\\hr\\photo\\No-image-
- found.jpg");
- }
Jay StewartPosted Jun 2, 2017, 7:13 AM
Hamizah TALHAHPosted May 31, 2017, 12:35 AM
Rajeev PunhaniPosted May 30, 2017, 11:30 PM