Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 2 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
add comment

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.