It is necessary to upload a pictureBox picture by relative link. The picture in the folder img. I tried this: img \ gogol.jpg
3 answers
You can upload a picture from a file in PictureBox
var pb = new PictureBox(); pb.Image = new Bitmap(@"img\gogol.jpg"); The full path to the file can be obtained as follows.
var path = System.IO.Path.GetFullPath(@"img\gogol.jpg"); |
Make sure that when the application is running, the current directory of the application you have is the one in which your exe is located (You can see in the process explorer in the process properties). Then the relative path can be specified as follows. \ Img \ gogol.jpg
|
var dir = Directory.GetCurrentDirectory() + "\\img\\gogol.jpg"; |
