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?
Euless_TechAsked:
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 Specialist/DeveloperCommented:
0
Euless_TechAuthor Commented:
So Shaun, would the PDFs be part of a list or can I send them as documents within a document library?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
You can do both but I recommend document library
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Euless_TechAuthor Commented:
So do I create a document library and then just move the objects into it?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
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(
    fileCreationInformation);

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

uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();

}
}

Open in new window

https://stackoverflow.com/questions/9847935/upload-a-document-to-a-sharepoint-list-from-client-side-object-model
0
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.
0
Euless_TechAuthor Commented:
Shaun,
I'm having trouble locating the Microsoft.SharePoint dlll to reference in my project. Any tips on finding it?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
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.
0
Euless_TechAuthor Commented:
Shaun,
I hate to be so dense, but do you know of an article that shows how to do that?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
No problem. Here is an article for 2016 but in it, there is a link to 2013 if you prefer
https://cann0nf0dder.wordpress.com/2016/08/30/building-sharepoint-2016-development-environment-part-1-introduction/
0
Euless_TechAuthor Commented:
Shaun,
We only have a SharePoint presence online. Is it possible to connect to that instance without a local installation?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Only if you use Client Side Object Model (CSOM)
0

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.