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

Re: Image.FromFile by Tim

Tim
Thu Dec 18 18:54:09 CST 2003

Use a constructor overload for the Bitmap class:
Bitmap bmp = Bitmap("tree1.gif");
myImageList.Images.Add(bmp);

--
Tim Wilson
.Net Compact Framework MVP

"Paul" <x_p_strong@hotmail.com> wrote in message
news:brth1k$gac$1@news8.svr.pol.co.uk...
> 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
>
>



Re: Image.FromFile by Tim

Tim
Thu Dec 18 18:56:42 CST 2003

Don't be like me and forget the "new" :)
Bitmap bmp = new Bitmap("tree1.gif");

--
Tim Wilson
.Net Compact Framework MVP

"Tim Wilson [MVP]" <Tim_Wilson@[DieSpamDie]Rogers.com> wrote in message
news:uUDzgpcxDHA.1804@TK2MSFTNGP09.phx.gbl...
> Use a constructor overload for the Bitmap class:
> Bitmap bmp = Bitmap("tree1.gif");
> myImageList.Images.Add(bmp);
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "Paul" <x_p_strong@hotmail.com> wrote in message
> news:brth1k$gac$1@news8.svr.pol.co.uk...
> > 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
> >
> >
>
>



Re: Image.FromFile by Chris

Chris
Thu Dec 18 20:36:09 CST 2003

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

"Tim Wilson [MVP]" <Tim_Wilson@[DieSpamDie]Rogers.com> wrote in message
news:uUDzgpcxDHA.1804@TK2MSFTNGP09.phx.gbl...
> Use a constructor overload for the Bitmap class:
> Bitmap bmp = Bitmap("tree1.gif");
> myImageList.Images.Add(bmp);
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "Paul" <x_p_strong@hotmail.com> wrote in message
> news:brth1k$gac$1@news8.svr.pol.co.uk...
> > 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
> >
> >
>
>