How do I push pdfs to a folder in sharepoint online?

We are wanting to push our direct deposit remittance documents to a folder on SharePoint Online for our employees.
Is it possible to connect to SharePoint in C# and transfer those files to a particular folder in SharePoint?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical SpecialistCommented:
Euless_TechAuthor Commented:
So Shaun, would the PDFs be part of a list or can I send them as documents within a document library?
Shaun VermaakTechnical SpecialistCommented:
You can do both but I recommend document library
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Euless_TechAuthor Commented:
So do I create a document library and then just move the objects into it?
Shaun VermaakTechnical SpecialistCommented:
Create document library, use C# to read documents as a byte array and submit to the document library via CSOM
public void UploadDocument(string siteURL, string documentListName,
string documentListURL, string documentName,

byte[] documentStream)

using (ClientContext clientContext = new ClientContext(siteURL))

//Get Document List
List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);

var fileCreationInformation = new FileCreationInformation();
//Assign to content byte[] i.e. documentStream

fileCreationInformation.Content = documentStream;
//Allow owerwrite of document

fileCreationInformation.Overwrite = true;
//Upload URL

fileCreationInformation.Url = siteURL + documentListURL + documentName;
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(

//Update the metadata for a field having name "DocType"
uploadFile.ListItemAllFields["DocType"] = "Favourites";



Open in new window
Euless_TechAuthor Commented:
Thanks Shaun. Give me a little bit to try things and if all goes as planned, I should be able to award the points and close the question.
Euless_TechAuthor Commented:
I'm having trouble locating the Microsoft.SharePoint dlll to reference in my project. Any tips on finding it?
Shaun VermaakTechnical SpecialistCommented:
Yes, for that DLL you need to have SharePoint installed on your dev computer. When I do SharePoint dev, I spin up an SPS cluster in Azure with Visual Studio.
Euless_TechAuthor Commented:
I hate to be so dense, but do you know of an article that shows how to do that?
Shaun VermaakTechnical SpecialistCommented:
No problem. Here is an article for 2016 but in it, there is a link to 2013 if you prefer
Euless_TechAuthor Commented:
We only have a SharePoint presence online. Is it possible to connect to that instance without a local installation?
Shaun VermaakTechnical SpecialistCommented:
Only if you use Client Side Object Model (CSOM)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.