I use the following code example to upload multiple files (using the sharepoint Object Model, no webservice) in the document library, but sometimes it throws an hresult exception: 0x80020009 with error code -2147352567 and the error message is empty (empty line), and the file loads successfully to the document library. And basically this only happens the first time it happens when the first document is loaded after the whole process went smoothly. An exception does not occur after the first time. If I eat this exception, it works fine. Can someone help me track the problem, I can’t understand why it throws an exception when the file is uploaded to the document library. I want to know what the actual reason is and what should I do to avoid this problem.
the code: .....
SPFolder folder = web.GetFolder(folderUrl);
foreach(.....)
{
folder.Files.Add(folderUrl + "/" + fileName, file.Data, true);
}