0
votes

I am using the following code to upload files in share point folders.

Dim lobjSourceFileCreateInfo As New FileCreationInformation()
                    lobjSourceFileCreateInfo.Content = System.IO.File.ReadAllBytes(lstrSourceFilePath)
                    lobjSourceFileCreateInfo.Overwrite = True

                   lobjSourceFileCreateInfo.Url = lstrFileRelativeURL
                   Dim lobjWebObj As Web = lobjClientContext.Web  


                    Dim llstListOfDoc As List = lobjWebObj.Lists.GetByTitle(pstrListName)
                    Dim lobjFiletoBeUploaded As MSSPClient.File = llstListOfDoc.RootFolder.Files.Add(lobjSourceFileCreateInfo)

                   lobjClientContext.Load(lobjFiletoBeUploaded)
                    lobjClientContext.ExecuteQuery()

But I am getting the following error: Value does not fall within specified range. However I could able to upload files directly under the document library but not in the folders created under the document library.

2
I have given the complete URl for lobjSourceFileCreateInfo.Url and worked fine.Rupesh

2 Answers

0
votes

Your function seems to be fine. I would suggest you to check the path specified for the SharePoint folder as well as the file which is being uploaded.

0
votes

I think there's a problem with upload file size limit,

Please read the following article and try the code inside:

http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx