Hi.
In the following code my intention is to upload a file programmatically from a folder on disk to a SharePoint 2010 document library.
// Get the destination libraries
SPList destination = web.GetList(web.ServerRelativeUrl + sDocLib);
// Get the root folder of the destination we'll use this to add the files
SPFolder folder = web.GetFolder(destination.RootFolder.Url);
web.AllowUnsafeUpdates = true;//SPFile curFile = web.Folders[sDocLib].Files.Add(sSourceFile, content);SPFile curFile = folder.Files.Add(web.Url + "/" + folder.Url + "/" + sSourceFile, content, true);
web.Folders[sDocLib].Update();But the code crashes on both the SPFile curFile = web.Folders line for both the commented out line of code and the uncommented line of code.
It crashes with no error when debugging. I can upload to the document library manually. I am running this directly on the server and debugging it in Visual Studio 2010. This piece of code worked fine in SharePoint 2007.
Any ideas what the problem is?