INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Get image file based on text box file name proplem

Get image file based on text box file name proplem

(OP)
I have windows form have 3 controls
1-textbox1
2-button
3-picture box1
what i need is to display image in picture box1 when i press button
to show the file name that written in textbox by searching the file in shared folder in network and if found it show it
example
I have shared folder"D:/images" have all permissions and is accessible found in server 192.168.1.10 and it shared folder and have all pictures to all employee
What i need is when i write 111 in textbox1 and press button then it will go search in folder images"D:/images" found in network in server 192.168.1.10 and search for file that have 111 image
if it found show it in picture box1
Are this possible?
I need code by c# to make or achieve this task above.
thanks

RE: Get image file based on text box file name proplem

Yes it is all possible.

What have you written so far?

RE: Get image file based on text box file name proplem

(OP)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing.Imaging;
using System.IO;

namespace FleetManagment
{
{
FleetManagment.Fleet fleet2 = new FleetManagment.Fleet();
private void button2_Click(object sender, EventArgs e)
{
try
{
string[] fileNames = Directory.GetFiles("D:\\Images");
foreach (string file in fileNames)
{

if (file.Contains(textBox1.Text))
{
pictureBox1.Image = Image.FromFile(Path.Combine("D:\\Images", textBox1.Text) + ".jpg");
}
else
{
MessageBox.Show("File not exist");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString ());
}

}
}
}
The code above is get picture from local machine and work successfully what i need is :
1- get image from server 192.168.1.10 in folder path D:/images
2-if folder images not have image written in textbox and press
any file name wrong in textbox it give me exception
how to prevent exception from show

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close