0

In my adding_form, I using this code to browse image from its project bin to display as customer picturebox background. I run project in design it is working as well, but after publishing as an .exe file and install to the local computer or different computer it doesn't browse this bg any more.

    private void loadimage()
    {
        try
        {
            string path = Environment.CurrentDirectory + "\\image\\bguser.png";
            if (File.Exists(path))
            {
                piccustomer.Image = null;
                this.piccustomer.Image = System.Drawing.Image.FromFile(path);
            }
        }
        catch (SqlException ex)
        {
            MessageBox.Show(ex.ToString());
            return;
        }
    }

After inserting the data successfully, it follows with cleartext() @it is the method to clear all texts. And I put this to clear picturebox and load bg again.

        piccustomer.Image = null;
        loadimage();

but the loadimage() is not working.

What is wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Sai
  • 47
  • 7
  • After you set the picture invalidate the control so it is redrawn. `this.piccustomer.Invalidate()` – Sorceri May 30 '18 at 16:11
  • SqlException is way off the mark. You should not rely on CurrentDirectory, See https://stackoverflow.com/questions/15653921/get-current-folder-path? – Alex K. May 30 '18 at 16:17

0 Answers0