How to get a valid Image

M

Martijn Mulder

At startup my application loads an image from a file from disk. If the file
is not there, I still need a valid System.Drawing.Image object but I don't
know how to get one.




//class MyImage
class MyImage
{

//data member image
System.Drawing.Image image;

//constructor
public Image():this(@"c:\Some Directory\Some Image.jpg"){}
public Image(string a)
{
try
{
image=System.Drawing.Image.FromFile(a);
}
catch
{
image=...
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top