Loading PictureBox Image from resource file with path (Part 3)

前端 未结 5 900
北荒
北荒 2020-12-03 07:19

I understand that this question has been asked (and answered) before. However, none of the solutions are working for me.

Below is a screen capture of all the relevan

5条回答
  •  醉酒成梦
    2020-12-03 07:51

    It depends on your file path. For me, the current directory was [project]\bin\Debug, so I had to move to the parent folder twice.

    Image image = Image.FromFile(@"..\..\Pictures\"+text+".png");
    this.pictureBox1.Image = image;
    

    To find your current directory, you can make a dummy label called label2 and write this:

    this.label2.Text = System.IO.Directory.GetCurrentDirectory();
    

提交回复
热议问题