I need to upload a CSV or Excel file to a SharePoint folder using a C# application. Could you please assist with this?
How can this be accomplished in C#?
Loading
I need to upload a CSV or Excel file to a SharePoint folder using a C# application. Could you please assist with this?
How can this be accomplished in C#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Nov 20, 2024, 3:42 PM
Hi Jignesh,
https://learn.microsoft.com/en-us/answers/questions/1517434/how-to-upload-a-file-to-a-sharepoint-driveitem-fol
https://medium.com/@mitchelldalehein25/uploading-files-to-sharepoint-using-microsoft-graph-api-c-0edc689fb388
Jayraj ChhayaPosted Nov 20, 2024, 10:51 AM
Hi
The
SharePointOnlineCredentialsclass is part of the SharePoint Client Components SDK, which is compatible with .NET Framework versions 4.5 and later. This class is specifically designed for authenticating against SharePoint Online using the SharePoint Client Object Model.To utilize
SharePointOnlineCredentials, ensure that you have the appropriate NuGet package installed, typicallyMicrosoft.SharePointOnline.CSOM.Once the package is installed, you should be able to use
SharePointOnlineCredentialswithout any issues. If you are still encountering problems, verify that your project is targeting a compatible version of the .NET Framework and that all necessary references are correctly set up.This line effectively sets the credentials for the
ClientContext, allowing you to interact with SharePoint Online securely.Jignesh KumarPosted Nov 20, 2024, 9:15 AM
In which version it will work ?
I am not getting this one SharePointOnlineCredentials()
Jayraj ChhayaPosted Nov 20, 2024, 9:11 AM
Hi @Jignesh Kumar,
To upload an Excel or CSV file to a SharePoint folder using C#, you can leverage the SharePoint Client Object Model.
NOTE :- Replace the placeholders with your actual SharePoint site URL, folder path, and file details. This code establishes a connection to SharePoint, reads the specified file, and uploads it to the designated folder. Ensure you have the necessary permissions and references to the SharePoint Client assemblies in your project.