Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Speed up retrieve image into picturebox
Hamizah TALHAH
May 30 2017 10:13 PM
261
Reply
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");
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Split table using VSTO
How to insert Blank page in current document.