Home > SharePoint - Tips & Tricks > Como fazer Upload de arquivos no SharePoint 2010 usando Client Object Model

Como fazer Upload de arquivos no SharePoint 2010 usando Client Object Model


Olá! Smile

Para fazer upload de arquivos no SharePoint 2010 usando o Client Object Model, use o seguinte código:

Code Snippet
  1. using (ClientContext clientContext = new ClientContext("http://notebook01/sites/bi"))
  2.                 {
  3.                     using (FileStream fs = new FileStream("Chart.xlsx", FileMode.Open))
  4.                     {
  5.                         Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, "/sites/bi/Documents/Chart.xlsx", fs, true);
  6.                     }                    
  7.                 }

 

Lembre-se de adicionar as Referências necessárias para utilizar o Client OM do SharePoint 2010.

image

Code Snippet
  1. using Microsoft.SharePoint.Client;

 

Abraço!

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: