-
June 2nd, 2014, 02:54 PM
#1
get image based on textbox proplem
Hi guys i have proplem I have image file jpg and his name 111.jpg found in another computer in domain in shared folder
I need when i write in textbox 111 and click button get picture with name 111.jpg
from shared folder in network and get it to local computeres work in domain
how i get or making this by c# code
-
June 2nd, 2014, 05:14 PM
#2
Re: get image based on textbox proplem
Browse for the File, if you have permission, it should show up.
-
June 3rd, 2014, 12:01 AM
#3
Re: get image based on textbox proplem
I can browse it without permission
can you give me code that achieve this task
-
June 3rd, 2014, 12:12 AM
#4
Re: get image based on textbox proplem
-
June 7th, 2014, 03:45 AM
#5
Re: get image based on textbox proplem
Originally Posted by dglienna
-
June 7th, 2014, 03:48 AM
#6
Re: get image based on textbox proplem
the case what i need is above
what i need is to when i write employee no in text box1
and press button1 go to path in shared folder in server 192.168.1.10 and show image that found in shared folder have all permission 192.168.1.10/D:/images if found
please help me in this task
-
June 7th, 2014, 01:12 PM
#7
Re: get image based on textbox proplem
Looks like you're file is in the F: drive
-
June 8th, 2014, 06:05 PM
#8
Re: get image based on textbox proplem
It's not clear what the problem is.
Do you have code that displays the FolderBrowserDialog? If so..
In the fb dialog can you navigate to the network drive? If so..
Are you able to retrieve the full network path to the file? If so..
Does the image display?
Does any of this work with an image on a local drive?
Please create a small test app, zip it up and post it here.
-
June 9th, 2014, 06:21 AM
#9
Re: get image based on textbox proplem
Originally Posted by Arjay
It's not clear what the problem is.
Do you have code that displays the FolderBrowserDialog? If so..
In the fb dialog can you navigate to the network drive? If so..
Are you able to retrieve the full network path to the file? If so..
Does the image display?
Does any of this work with an image on a local drive?
Please create a small test app, zip it up and post it here.
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
-
June 9th, 2014, 12:12 PM
#10
Re: get image based on textbox proplem
Your logic is incorrect for loading the file as an image.
Instead of using the textbox1.text value, use file.FullName
if (file.Contains(textBox1.Text))
{
pictureBox1.Image = Image.FromFile(Path.Combine(file.FullName);
}
...
Actually, this whole logic is wrong because if there are more than one file in the folder, you will always get the "File not Exist" message box.
If you need to capture an exception, use a try/catch block.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|