SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To upload a file using File.SaveBinaryDirect you have to know the server relative URL of the document library you're working with.

Example from MSDN :-

ClientContext clientContext = new ClientContext("http://intranet.contoso.com");
using (FileStream fileStream = new FileStream("NewDocument.docx", FileMode.Open))
{
   ClientOM.File.SaveBinaryDirect(clientContext,
            "/Shared Documents/NewDocument.docx", fileStream, true);
}

How can you determine a Document Libraries url?

share|improve this question
up vote 4 down vote accepted
docLib = Context.Web.Lists.GetByTitle("Your Doclib Name");

Context.Load(docLib);
Context.Load(docLib.RootFolder);
Context.ExecuteQuery();

string serverRelativeUrl = docLib.RootFolder.ServerRelativeUrl;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.