Is there any way of finding out what type an image is when embedded in a picturebox.
For example, if someone loaded "C:\mypicture.jpg" into a picturebox then how can I find out if the image is jpg or bmp without knowing the source ?
Printable View
Is there any way of finding out what type an image is when embedded in a picturebox.
For example, if someone loaded "C:\mypicture.jpg" into a picturebox then how can I find out if the image is jpg or bmp without knowing the source ?
You can't
Once it's in the picturebox it has lost all information of where it came from.
If you populate a .NET 2.0 PictureBox by calling the Load method or by setting the ImageLocation property then the original file path will be accessible via the ImageLocation property. This beats using Image.FromFile as it doesn''t lock the file either.