Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I develop pocket pc.
I have a public property with attribute [EditorBrowsable()].
When I try to load *.ico format into Image and summon some function I get an error in GDI+. How to exclude *.ico format from OpenFileDialog in Design-time or get ImageFormat from Image?
Sorry for my English.
thx.
Posted

File Dialogs have a Filter[^] property that allows you to exclude any file types that you don't want. If you set it to only show files of image types (bmp, jpg, and png for example) then you can be fairly sure that the file path it returns won't cause problems when you load it using the Image class.

When loading a file using Image.FromFile or something equivalent it's always good to put a try - catch around the call just in case the image is valid. That should catch the case of trying to load an Icon (or something else) into an Image.
 
Share this answer
 
I know that. But how to set filter on OpenFileDialog in Design time?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900