Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have a winform app in c# with 2 forms.
in form 1 the user selects an image from a picturebox and after clicking next that image is displayed in form 2 with a bunch of new information.
This works but i have a problem, with the code i have the image is copied instead of opened again in form 2. If i publish the app i get an error in form 2 saying that the image file could not be found in the folder ..@/Images/
witch is created when i debug but not when i publish, so if the app opens the same file instead of copying it, it should work... i think.
The the image in form1 comes from a picturebox and is added in the designer.

The code i use is the following:
FORM 1:

C#
private void button1_Click(object sender, EventArgs e)
{
    if (radioButton1.Checked)

        build build = new build("@../Images/JAF.jpg", "item description", "c1");
        build.ShowDialog();


What I have tried:

FORM 2:

C#
public build(string img_from_A, string desc, string id)
       {
           InitializeComponent();
           pictureBox2.Load(img_from_A);
           desc1.Text = desc;
           this.prumos = id;
Posted
Updated 24-Nov-16 1:23am
v5
Comments
Richard MacCutchan 24-Nov-16 5:02am    
You need to check the location of the file is valid. You also should not use relative file paths like that, but get the correct full path where the file is located.

Also, I think your '@' sign is in the wrong place.
Marc-IT 24-Nov-16 9:48am    
Thanks for the help, but if i use full path wont the app crash when it is installed on another computer?
the path wont be the same
is it possible to copy it from memory?
loading form 2 would use the image from from 1 but not copy it.
something like:
PictureBox2.Image = PictureBox1.Image.Clone
Richard MacCutchan 24-Nov-16 12:28pm    
You just need to adjust the path when installing it. A better way of doing it is to use one of the Environment.SpecialFolder Enumeration (System)[^] and make sure you install your data in the same place on each system.
Karthik_Mahalingam 24-Nov-16 9:35am    
Always use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.
Marc-IT 24-Nov-16 9:49am    
thanks for the tip i didnt see the button :|

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900