• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1061
  • Last Modified:

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);
            ctx.Load(site.Lists);
            //ctx.Load(site, x => x.Lists.Where(l => l.Title != null));
            ctx.ExecuteQuery();
            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

 this._thumbnails.Add(
             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
5.JPG
0
fatihdi
Asked:
fatihdi
1 Solution
 
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);


0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now