Image.FromFile

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,
I'm having problems adding pictures to an imagelist using a filename in my
working directory. Heres the code i'm trying use -
myImageList.Images.Add(System.Drawing.Image.FromFile("tree1.gif"));

I get complaints about using from file i guess its because it does not
exist for the compact framework, is there another way of doing the same
thing.

Thanks,

Paul
 
Use a constructor overload for the Bitmap class:
Bitmap bmp = Bitmap("tree1.gif");
myImageList.Images.Add(bmp);
 
Also keep in mind that CE has no notion of a "working directory". It's all
absolute based. Using no path or slash may correctly load it from the
directory your app is in, but it's far safer to either hardcode the full
path or find the path of the executing assembly and preface the file name
with it.

-Chris
 
Back
Top