Hi @Murari Ram ,
You could try to use SSOM or CSOM.
My test SSOM code for your reference(SSOM can only be used for SharePoint Server):
String fileToUpload = @"C:\Users\Administrator.CONTOSO\Desktop\workflowList.csv";
String sharePointSite = "http://sp";
String documentLibraryName = "Shared Documents";
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File not found.", fileToUpload);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
// Prepare to upload
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
// Commit
myLibrary.Update();
}
}
More threads for your reference:
- How to: Upload a File to a SharePoint Site from a Local Folder
- Upload A Document To A SharePoint 2013 Library Using Client Side Object Model
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.