I have created a Silverlight Application that runs in a SharePoint 2010 web part.
One requirement I have is to give the user a prompt to upload a file, and then send it into a specific Document Library with the additional Fields 'First' and 'Last' (Name corresponding to whom the document is from).
I am able to create the document and upload it to SharePoint. At this point however I hit an impasse. The normal means (as far as I'm aware) to add a Document to a Document Library is something similar to the following...
ClientContext context = new ClientContext(ApplicationContext.Current.Url); context.Load(context.Web); List docList = context.Web.Lists.GetByTitle("MyDocLib"); context.Load(docList); docList.RootFolder.Files.Add(myFile); // Assuming of course the file is retrieved already context.ExecuteQuery(); // Or ExecuteQueryAsync for more functionality
Unfortunately this leaves no room to add in the extra fields i need.
Furthermore the only thing received if i were to use something like
File file = docList.RootFolder.Files.Add(myFile);
does not seem to have an association with the library to build off of and then run another ExecuteQuery()
I would imagine there would be a way of treating the Document Library as a List (I'm fairly sure from a technical perspective they amount to the same thing) for its item creation, however I do not know how to create it properly.
If someone could give me advice on how to proceed, it would be much appreciated.