I need to get files inside a document library using silverlight Object Model from my silverlight application

hi i still have problem i am able to add

using Microsoft.SharePoint.Client;   to using namespace part of the program and I am able to  create ClientContext object and point it to the site i am using.  Now site, site.lists  comes as recognized keywords in my silverlight application, after adding Microsoft.Sharepoint.Client.Silverlight and Microsoft.Sharepoint.Client.Silverlight.Runtime dlls but now i need the code to get inside a sharepoint document library and get the images that are located in this document library and use images in my silverlight application  i used

            ClientContext ctx = new ClientContext("http://sharepoint-one");
            Web site = ctx.Web;
            //ctx.Load(site, x => x.Lists.Where(l => l.Title != null));
            foreach (List list in site.Lists)


this code but it gave error stating list is not initialized? i know i need to use something similar ,i am a newbie so i dont know how to achieve this what is the code for me to achieve what i want?

// old version i need to change it for taking the p11.jpg from document library

             new Thumbnail

                 //Picture = PREFIX +
                 //    "0/03/JROppenheimer-LosAlamos.jpg" +
                 //    "/200px-JROppenheimer-LosAlamos.jpg"

                 Picture = PREFIX + "p11.jpg"

.. I want to take the pictures from the document library instead of web server etc.. in my silverlight application .. How can I achieve this ? I need source code for retriving the files inside the document library and provide it to my web gallery silverlight application in the attachment you can see that i was adding the pictures with this.thumbnails.Add object  now instead i need to make use of the ClientContext ,Site.Lists etc ... to achieve this...... pls i need help ..I am attaching the code I used to achieve it but it gave an error that list collection did not initialize ?? please check the snapshot as well thank you for helping....

I am using Sharepoint 2010 and Silverlight
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shailaja KumarCommented:
You need to add reference to the Microsoft.SharePoint.dll, inorder for you to manipulate with the sharepoint objects,

You can try the following code for downloading the images,
SPWeb web = new SPSite(siteurl).OpenWeb();
  //Open List
  SPList list = web.Lists["ListName"];
  //Get the item
  SPListItem item = list.Items[itemid];
  SPFile file= item.file;
  byte[] binFile = file.OpenBinary();
   System.IO.FileStream fstream = System.IO.File.Create("c:\\MyDownloadFolder\\" + file.Name);
   fstream.Write(binFile, 0, binFile.Length);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fatihdiAuthor Commented:
nope it did not solve the problem in Client Object Model you dont have the SP in the begining of the words...and also this is for a list i guess i want the document library
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.