I have some code that runs fine on a SP2013 server that opens a SharePoint file and processess it as a memory stream. I need to have the same working for a 2010 server.

Using the same code and the most recent client and runtime DLLs I am able to connect to the server and the library but I get an error "Method "OpenBinaryStream" does not exist" When the following line executes:

ClientResult<Stream> fileContents = file.OpenBinaryStream();

I have checked its supported in 2010. It shows up in intellisense and doesn't have a problem compiling.

Here is the full code:

class Program
    static void Main(string[] args)
        string serverURL = "http://SP2010";
        string libraryName = "Documents";
        ClientContext context = new ClientContext(serverURL);

        List myList = context.Web.Lists.GetByTitle(libraryName);
        CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
        ListItemCollection items = myList.GetItems(query);

        // Retrieve all items in the ListItemCollection from List.GetItems(Query). 
        foreach (ListItem listItem in items)
            string fileText = string.Empty;

            Microsoft.SharePoint.Client.File file = listItem.File;


            string fileUrl = file.ServerRelativeUrl;

                ClientResult<Stream> fileContents = file.OpenBinaryStream();
                MemoryStream fileContentStream = new System.IO.MemoryStream();
                fileText += extractor.TextFromTextFile(fileContentStream);

Any ideas very much appreciated.

Thanks Bren

3 Answers 3


It does not appear to be supported in Microsoft.SharePoint.Client.dll in SharePoint 2010. The link you provided to MSDN was for Microsoft.SharePoint.dll.

  • 1
    Sergey reread the original post, they're using the client namespace, which lacks that method. You posted the SSOM method.
    – user6024
    Commented May 18, 2017 at 14:14
  • I apologize for inconvenience, have posted the wrong link. Removed my old to not to mislead. OpenBinaryDirect method is correct.
    – Sergey
    Commented May 20, 2017 at 8:33

Thanks for the pointers, here is the working code which uses the OpenBinaryDirect and pushes it into a memory stream.

FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(context, fileUrl);

                using (var ms = new MemoryStream())
                    var buf = new byte[1024 * 16];
                    int byteSize;
                    while ((byteSize = fileInfo.Stream.Read(buf, 0, buf.Length)) > 0)
                        ms.Write(buf, 0, byteSize);

                    fileText += extractor.TextFromDOCX(ms);
  • Please make sure to mark this as an answer when you're able!
    – user6024
    Commented Jun 2, 2017 at 14:59

for anyone else scratching there head ... this can be done using the client library but OpenBinaryDirect is static I was trying to call it on the instance so I couldn't find it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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