Experts Exchange connects you with the people and services you need so you can get back to work.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim metaData = New Dictionary(Of String, String)
metaData.Add("Title", "My Document Title")
metaData.Add("CustomProp", "My custom property")
MessageBox.Show(UploadDocument("TestFile1.txt", "D:\\TestUpload1.txt", metaData))
Public Function UploadDocument(fileName As String, filePath As String, metaDataDictionary As Dictionary(Of String, String)) As Boolean
Dim ctx As New ClientContext("http://dev.rainerj.local/sites/ee")
Dim currentWeb As Web = ctx.Web
Dim fileToUpload As FileCreationInformation = New FileCreationInformation
fileToUpload.Content = System.IO.File.ReadAllBytes(filePath)
fileToUpload.Url = "http://dev.rainerj.local/sites/ee/EEMCOM/" + fileName
Dim docLib As Microsoft.SharePoint.Client.List = currentWeb.Lists.GetByTitle("EEMCOM")
Dim uploadedFile As Microsoft.SharePoint.Client.File = docLib.RootFolder.Files.Add(fileToUpload)
Dim item As ListItem = uploadedFile.ListItemAllFields
For Each key As String In metaDataDictionary.Keys
item(key) = metaDataDictionary(key)
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.