SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know if i can upload a document to sharePoint document library using batch in C#. I know how to update and delete it using batch, but i don't know how to upload it.

If i can't, what is the best way to upload a document with metadata?

Thanks alot.

share|improve this question
up vote 1 down vote accepted

I think it can't be done. So i did the following:

1- I uploaded a document to the document library using a web request.
2- I updated the metadata of this document using the batch update command.

If anyone have a different approach please share it.


share|improve this answer

I don't know how to add metadata. But to upload a document you can map the document library to an unused drive letter and copy the file to the document library

net use x: \\path\to\sharepoint\document\library
copy x:
share|improve this answer

Here follow some code snippet to help you with file upload... Considering that you'll upload to a Document Library...

    spWeb.AllowUnsafeUpdates = True

    Dim strUrl As String = spWeb.Lists("DocLib").RootFolder.ServerRelativeUrl.ToString()

    Dim spFolderCollection As SPFolderCollection = spWeb.GetFolder(strUrl).SubFolders

    Dim spFolder As SPFolder = spFolderCollection.Item("FolderName")

    spFolder.Files.Add(fileName, stream, replaceExistingFiles)


    spWeb.AllowUnsafeUpdates = False
End Try
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.