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 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");
- }