Question

I'll try to be simple and quick

I'm developing a program, a windows form actually. I have a pictureBox and in the following line, when I run in debug mode(note that), I get an System.IO.FileNotFoundException exception:

pictureBox1->Image = Image::FromFile(".\\images\\no-avatar2.jpg");

The problem is that I don't get that exception when I run the exe file AND the file loads perfectly. Any ideas why this happens?

Was it helpful?

Solution

I use this:

pictureBox1->Image = Image::FromFile(System::IO::Path::GetDirectoryName(System::Reflection::Assembly:‌:GetEntryAssembly()->Location) + "\\images\\no-avatar2.jpg");

and it works perfectly

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top