0
        private Bitmap img;
    public void ShowMyImageTrayType(String fileToDisplay, int xSize, int ySize)
    {
        if (img != null)
        {
            img.Dispose();
        }
        pBoxTraySize.SizeMode = PictureBoxSizeMode.StretchImage;
        img = new Bitmap(fileToDisplay);
        pBoxTraySize.ClientSize = new Size(xSize, ySize);
        pBoxTraySize.Image = img;
    }

I use the above code to display image inside PictureBox but I get (Parameter is not valid.) error

Mohamed Ahmed
  • 113
  • 11
  • When/Where do you get that error? – Stephan Bauer Mar 07 '19 at 09:39
  • Sorry for this written mistake I edit the question – Mohamed Ahmed Mar 07 '19 at 09:39
  • your code as it is works pretty fine. I just tested it. Most probably your path is wrong. please show us the value of `fileToDisplay`, and preferably a screenshot that shows that this file also exists in the designated path – Mong Zhu Mar 07 '19 at 09:42
  • fileToDisplay value @"D:\test\SourceDWGs\CableTray-Plugin\Support\CableLadder\CableLadder\Cable Ladder.jpg" the code was working fine but Suddenly stop – Mohamed Ahmed Mar 07 '19 at 09:46
  • Possible duplicate of [C# "Parameter is not valid." creating new bitmap](https://stackoverflow.com/questions/6333681/c-sharp-parameter-is-not-valid-creating-new-bitmap) – Stephan Bauer Mar 07 '19 at 09:46
  • how about the screenshot with the file in this folder? – Mong Zhu Mar 07 '19 at 09:55
  • [Image img](https://33333.cdn.cke-cs.com/rc1DFuFpHqcR3Mah6y0e/images/9a2ef66591a6aa58107961db3594f6feb7dd7fafb748927f.JPG/w_673) – Mohamed Ahmed Mar 07 '19 at 10:02
  • this is getting tidious. from your picture, I can see only that the filename seems to be correct. ok I guess you assured yourself, that the path is correct and that there are no typos. If so, than I would read the answers in the possible duplicate that Stephan Bauer posted in his comment. – Mong Zhu Mar 07 '19 at 10:36

0 Answers0