FileCollection.Add Method
Adds a file to the collection based on provided file creation information.
Assemblies: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll); Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll)
Parameters
- parameters
- Type: Microsoft.SharePoint.Client.FileCreationInformation
File creation information
It must not be null.
| Exception | Condition |
|---|---|
| [Microsoft.SharePoint.SPDuplicateValuesFoundException] |
The list item could not be updated because duplicate values were found for one or more field(s) in the list. Error code: -2130575169. |
| [Microsoft.SharePoint.SPException] |
Virus checking indicates the file is infected with a virus or the file is too large. Error code: -2146232832. |
| [Microsoft.SharePoint.SPFileCheckOutException] |
The file in the collection is not checked out. Error code: -2147024738. |
| [Microsoft.SharePoint.SPFileCheckOutException] |
The file in the collection is already checked out. Error code: -2130575306. |
| [Microsoft.SharePoint.SPFileLockException] |
The file in the collection is not locked. Error code: -2147024729. |
| [Microsoft.SharePoint.SPFileLockException] |
The file in the collection has bad lock argument. Error code: -2147023436. |
| [Microsoft.SharePoint.SPFileLockException] |
There is a shared lock on the file in the collection. Error code: -2147018894. |
| [Microsoft.SharePoint.SPFileLockException] |
There is an exclusive lock on the file in the collection. Error code: -2147018887. |
| [Microsoft.SharePoint.SPInvalidLookupValuesException] |
The list item could not be updated because invalid lookup values were found for one or more fields in the list. Error code: -2130575159. |
| [System.ArgumentException] |
URL of the file creation information must not be null and URL of the file creation information must not be invalid. Error code: -2147024809. |
| [System.ArgumentNullException] |
Content of the file creation information must not be null. Error code: -2147467261. |
| [System.ArgumentOutOfRangeException] |
There is a mismatch between the size of the document stream written and the size of the input document stream. Error code: - 2146233086. |
The .Add() method can also throw a System.Net.WebException so you may wish to look to include a catch block for this type. Here is some more information here on the issue.
The exceptions listed above seem to be incorrect how can the Client OM reference the Server OM?
The exceptions seem to be passed back to this class: Microsoft.SharePoint.Client.ServerException
So all of the exceptions that reference Microsoft.SharePoint should all be caught from this Exception class. It will then store the orginal error type in the ServerErrorTypeName Property (match these to the list above) and in the ServerErrorCode Property you will see the Error Codes (again match to the list above).
- 2/16/2011
- Adam Carr