Two ways to Upload file from Client Object Model

Hi Guys,

Just  a quick example, Take a scenario that you are creating an Application (in our case WinForm Application). and you want to upload a document to document library from that application, there are two ways to do, One is to upload from filecreation and the other one is to directly upload with file.savebinary method.

public void uploadfile(string siteurl,string fileName,string libraryName, string subfolderPath)

using (ClientContext clientContext = new ClientContext(siteUrl))

string uploadLocation = string.Empty;
if (!string.IsNullOrEmpty(
{uploadLocation = string.Format("/{0}/{1}/", libraryName, subfolderPath);}
uploadLocation = string.Format("/{0}/", libraryName);

#region Upload through filecreation
var fileCreationInformation = new FileCreationInformation();

byte[] bytefile = System.IO.File.ReadAllBytes(fileName);
fileCreationInformation.Content = bytefile;
fileCreationInformation.Overwrite = true;
uploadLocation = uploadLocation + Path.GetFileName(fileName);
fileCreationInformation.Url = uploadLocation;


#region Uploading directly
using (FileStream fs = new FileStream(fileName, FileMode.Open))

Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, uploadLocation, fs, true);






Please don’t forget to cast your opinion below about this blog
Happy SharePointing,

Download multiple file as Zip in SharePoint 2010

Today i have come across with a question from my friend, (Syed Ahmed Osama). He was trying to create a feature which enables to download multiple files as a single zip file.

After googling it for some time, i found a very nice feature

In order to deploy it, you can use the following post

(For the step 4 mention in the above blog, use this ps command

Install-SPSolution -Identity 2010_5_DeviantPoint.DownloadZip.wsp -GACDeployment -force

(stsdam won’t be available for the next version, so get yourself ready guys 🙂 )

It works for me like a charm, All marks to Bart X. Tubalinal. Good job mate

Happy SharePointing